• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang fakes.FakeCliConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection的典型用法代码示例。如果您正苦于以下问题:Golang FakeCliConnection类的具体用法?Golang FakeCliConnection怎么用?Golang FakeCliConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FakeCliConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestGetApps

func TestGetApps(t *testing.T) {
	conn := new(fakes.FakeCliConnection)

	content, fileReadErr := readFile("test-data/apps.json")

	if fileReadErr != nil {
		panic("Failed to read file: " + fileReadErr.Error())
	}

	conn.CliCommandWithoutTerminalOutputReturns(content, nil)

	cmd := new(DiegoMigrationCmd)

	space := Space{AppsUrl: "/fake-apps-url"}

	apps, err := cmd.getApps(conn, space)

	if err != nil {
		t.Errorf("getApps Returned an error: %v", err.Error())
	}

	if len(apps.Resources) == 0 {
		t.Error("expected at least one result from getApps")
	}

	for _, appResource := range apps.Resources {
		if appResource.Entity.Name == "" {
			t.Error("Name was null on SpaceResource.Entity")
		}
	}
}
开发者ID:pivotalservices,项目名称:diego-migration-plugin,代码行数:31,代码来源:diegomigration_test.go


示例2: TestGetOrgs

func TestGetOrgs(t *testing.T) {
	conn := new(fakes.FakeCliConnection)

	content, fileReadErr := readFile("test-data/orgs.json")

	if fileReadErr != nil {
		panic("Failed to read file: " + fileReadErr.Error())
	}

	conn.CliCommandWithoutTerminalOutputReturns(content, nil)

	cmd := new(DiegoMigrationCmd)

	orgs, err := cmd.getOrgs(conn)

	if err != nil {
		t.Errorf("getOrgs Returned an error: %v", err.Error())
	}

	if len(orgs.Resources) == 0 {
		t.Error("expected at least one result from getOrgs")
	}

	for _, orgResource := range orgs.Resources {
		if orgResource.Entity.SpacesUrl == "" {
			t.Error("SpacesURL was null on OrgResource.Entity")
		}

		if orgResource.Entity.Name == "" {
			t.Error("Name was null on OrgResource.Entity")
		}
	}
}
开发者ID:pivotalservices,项目名称:diego-migration-plugin,代码行数:33,代码来源:diegomigration_test.go


示例3: getAllCfCommands

func getAllCfCommands(connection *fakes.FakeCliConnection) (commands []string) {
	commands = []string{}
	for i := 0; i < connection.CliCommandCallCount(); i++ {
		args := connection.CliCommandArgsForCall(i)
		commands = append(commands, strings.Join(args, " "))
	}
	return
}
开发者ID:gerhard,项目名称:cf-blue-green-deploy,代码行数:8,代码来源:blue_green_deploy_test.go


示例4:

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app"
	"github.com/cloudfoundry/cli/plugin"
	"github.com/cloudfoundry/cli/plugin/fakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("App", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		curler            models.Curler
		af                app.AppFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
	})

	JustBeforeEach(func() {
		af = app.NewAppFactory(fakeCliConnection, curler)
	})

	Describe("Get", func() {
		Context("when CC returns a valid app guid", func() {
			BeforeEach(func() {
				fakeCliConnection.CliCommandWithoutTerminalOutputStub = func(args ...string) ([]string, error) {
开发者ID:sykesm,项目名称:diego-ssh,代码行数:31,代码来源:app_test.go


示例5:

package diego_support_test

import (
	"errors"

	"github.com/cloudfoundry/cli/plugin/fakes"

	"github.com/cloudfoundry-incubator/diego-enabler/diego_support"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("DiegoSupport", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		diegoSupport      *diego_support.DiegoSupport
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{""}, nil)
		diegoSupport = diego_support.NewDiegoSupport(fakeCliConnection)
	})

	Describe("SetDiegoFlag", func() {
		It("invokes CliCommandWithoutTerminalOutput()", func() {
			diegoSupport.SetDiegoFlag("123", false)

			Ω(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
		})
开发者ID:krishicks,项目名称:Diego-Enabler,代码行数:31,代码来源:diego_support_test.go


示例6:

package main

import (
	"github.com/cloudfoundry/cli/plugin/fakes"
	ioStub "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("appenv", func() {
	var fakeCliConnection *fakes.FakeCliConnection
	var appenv *AppEnv

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.IsLoggedInStub = func() (bool, error) { return true, nil }

		appenv = &AppEnv{}
	})

	Context("when uninstalled", func() {
		It("does nothing", func() {
			output := ioStub.CaptureOutput(func() {
				appenv.Run(fakeCliConnection, []string{"CLI-MESSAGE-UNINSTALL"})
			})

			Expect(output).To(ConsistOf([]string{""}))
		})
	})

	Context("when not logged in", func() {
开发者ID:Samze,项目名称:appenvs,代码行数:31,代码来源:appenv_test.go


示例7:

package info_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/info"
	"github.com/cloudfoundry/cli/plugin/fakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Info", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		infoFactory       info.InfoFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		infoFactory = info.NewInfoFactory(fakeCliConnection)
	})

	Describe("Get", func() {
		var expectedJson string

		JustBeforeEach(func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{expectedJson}, nil)
		})

		Context("when retrieving /v2/info is successful", func() {
开发者ID:sykesm,项目名称:diego-ssh,代码行数:31,代码来源:info_test.go


示例8: slurp

)

func slurp(filename string) []string {
	var b []string
	file, _ := os.Open(filename)
	defer file.Close()
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		b = append(b, scanner.Text())
	}
	return b
}

var _ = Describe("UsageReport", func() {
	var api *APIHelper
	var fakeCliConnection *fakes.FakeCliConnection

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		api = &APIHelper{}
	})

	Describe("Get orgs", func() {
		var orgsJSON []string

		BeforeEach(func() {
			orgsJSON = slurp("test-data/orgs.json")
		})

		It("should return two orgs", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns(orgsJSON, nil)
开发者ID:ahahtyler,项目名称:usagereport-plugin,代码行数:31,代码来源:apihelper_test.go


示例9: fakeError

	testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	// "os"
)

func fakeError(err error) {
	if err != nil {
		fmt.Println(err)
	}
}

var _ = Describe("WildcardPlugin", func() {
	var (
		ui                *testterm.FakeUI
		wildcardPlugin    *Wildcard
		fakeCliConnection *fakes.FakeCliConnection
		appsList          []plugin_models.GetAppsModel
	)
	Context("When running wildcard-apps", func() {
		BeforeEach(func() {
			appsList = make([]plugin_models.GetAppsModel, 0)
			appsList = append(appsList,
				plugin_models.GetAppsModel{"spring-music", "", "", 0, 0, 0, 0, nil},
				plugin_models.GetAppsModel{"app321", "", "", 0, 0, 0, 0, nil},
			)
			fakeCliConnection = &fakes.FakeCliConnection{}
			wildcardPlugin = &Wildcard{}
		})
		Describe("When there are matching apps", func() {
			It("prints a table containing only those apps", func() {
				fakeCliConnection.GetAppsReturns(appsList, nil)
开发者ID:lemaral,项目名称:Wildcard_Plugin,代码行数:32,代码来源:wildcard_plugin_test.go


示例10:

package main

import (
	"time"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Scaleover", func() {
	var scaleoverCmdPlugin *ScaleoverCmd
	var fakeCliConnection *fakes.FakeCliConnection

	Describe("getAppStatus", func() {

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			scaleoverCmdPlugin = &ScaleoverCmd{}
		})

		It("should Fail Without App 1", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"FAILED", "App app1 not found"}, nil)
			var err error
			_, err = scaleoverCmdPlugin.getAppStatus(fakeCliConnection, "app1")
			Expect(err.Error()).To(Equal("App app1 not found"))
		})

		It("should Fail Without App 2", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"FAILED", "App app2 not found"}, nil)
			var err error
开发者ID:TomG713,项目名称:scaleover-plugin,代码行数:31,代码来源:scaleover_test.go


示例11:

            "updated_at": "2015-07-09T17:00:44Z"
         },
         "entity": {
            "name": "staticfile-buildpack",
            "position": 10,
            "enabled": true,
            "locked": false,
            "filename": "staticfile_buildpack-cached-v1.2.0.zip"
         }
      }
   ]
}`

var _ = Describe("BuildpackRepo", func() {
	Describe("ListAll", func() {
		var cliConnection *fakes.FakeCliConnection

		BeforeEach(func() {
			cliConnection = &fakes.FakeCliConnection{}
		})

		It("outputs a slice of all admin buildpacks", func() {
			cliConnection.CliCommandWithoutTerminalOutputReturns([]string{getBuildpacksJson}, nil)

			repo := NewCliBuildpackRepository(cliConnection)
			buildpacks, _ := repo.ListBuildpacks()

			Expect(buildpacks[0].Name).To(Equal("java"))
			Expect(buildpacks[0].Position).To(Equal(1))
			Expect(buildpacks[0].Enabled).To(Equal(true))
			Expect(buildpacks[0].Locked).To(Equal(false))
开发者ID:davidehringer,项目名称:cf-buildpack-management-plugin,代码行数:31,代码来源:buildpack-repo_test.go


示例12:

import (
	"errors"
	"net/http"
	"os"

	cliFakes "github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/krujos/download_droplet_plugin/droplet"
	"github.com/krujos/download_droplet_plugin/droplet/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("DropletDownloader", func() {

	var fakeCliConnection *cliFakes.FakeCliConnection
	var downloader *CFDownloader
	var server *ghttp.Server
	tarFileContents := "This is a tar file"

	BeforeEach(func() {
		fakeCliConnection = &cliFakes.FakeCliConnection{}
		downloader = &CFDownloader{Cli: fakeCliConnection}
		server = ghttp.NewServer()
		fakeCliConnection.AccessTokenReturns("bearer 1234", nil)
		fakeCliConnection.ApiEndpointReturns(server.URL(), nil)
		fakeCliConnection.IsSSLDisabledReturns(true, nil)
		server.AppendHandlers(
			ghttp.VerifyRequest("GET", "/v2/apps/1234/droplet/download"),
			ghttp.VerifyHeader(
				http.Header{
开发者ID:krujos,项目名称:download_droplet_plugin,代码行数:31,代码来源:downloader_test.go


示例13:

package credential_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/credential"
	"github.com/cloudfoundry/cli/plugin/fakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Credential", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		credFactory       credential.CredentialFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		credFactory = credential.NewCredentialFactory(fakeCliConnection)
	})

	Describe("Get", func() {
		var expectedResponse []string

		Context("when retrieving /v2/info is successful", func() {
			BeforeEach(func() {
				expectedResponse = []string{
					"Getting OAuth token\n",
					"OK\n",
开发者ID:sykesm,项目名称:diego-ssh,代码行数:31,代码来源:credential_test.go


示例14: Fatalln

type FakeLogger struct {
	PrintSpy []string
}

func (s *FakeLogger) Fatalln(...interface{}) {
}

func (s *FakeLogger) Println(p ...interface{}) {
	fmt.Println(p)
	s.PrintSpy = append(s.PrintSpy, fmt.Sprint(p))
}

var _ = Describe("DeployCloudPlugin", func() {
	var (
		cliConn = new(cffakes.FakeCliConnection)
	)

	Describe("given .Run()", func() {
		Context("when called without valid arguments", func() {
			var (
				myLogger = new(FakeLogger)
				dcp      *DeployCloudPlugin
			)
			BeforeEach(func() {
				Logger = myLogger
				dcp = new(DeployCloudPlugin)
				dcp.Run(cliConn, []string{
					"cloud-deploy",
				})
			})
开发者ID:xchapter7x,项目名称:deploycloud,代码行数:30,代码来源:deploycloud_plugin_test.go


示例15:

			},
		)
		Ω(appName).Should(Equal("appname"))
		Ω(args).Should(Equal([]string{
			"push",
			"appname",
			"-f", "manifest-path",
			"-p", "app-path",
		}))
	})
})

var _ = Describe("Command Syntax", func() {

	var (
		cliConn         *fakes.FakeCliConnection
		autopilotPlugin *AutopilotPlugin
	)

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		autopilotPlugin = &AutopilotPlugin{}
	})

	It("displays push usage when push-zdd called with no arguments", func() {
		autopilotPlugin.Run(cliConn, []string{"push-zdd"})

		Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
		args := cliConn.CliCommandArgsForCall(0)
		Ω(args).Should(Equal([]string{"push", "-h"}))
	})
开发者ID:compozed,项目名称:autopilot,代码行数:31,代码来源:autopilot_test.go


示例16:

package main_test

import (
	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/cloudfoundry/cli/plugin_examples/call_cli_cmd/main"
	io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CallCliCmd", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var callCliCommandPlugin *CliCmd

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			callCliCommandPlugin = &CliCmd{}
		})

		It("calls the cli command that is passed as an argument", func() {
			io_helpers.CaptureOutput(func() {
				callCliCommandPlugin.Run(fakeCliConnection, []string{"cli-command", "plugins", "arg1"})
			})

			Expect(fakeCliConnection.CliCommandArgsForCall(0)[0]).To(Equal("plugins"))
			Expect(fakeCliConnection.CliCommandArgsForCall(0)[1]).To(Equal("arg1"))
		})

		It("ouputs the text returned by the cli command", func() {
			fakeCliConnection.CliCommandReturns([]string{"Hi", "Mom"}, nil)
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:call_cli_cmd_test.go


示例17:

package main_test

import (
	. "."
	"github.com/cloudfoundry/cli/plugin/fakes"
	io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cloud Foundry Copyenv Command", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var callCopyEnvCommandPlugin *CopyEnv

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			callCopyEnvCommandPlugin = &CopyEnv{}
		})

		It("Extract Application Name From Command Line Args", func() {
			name, err := callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv"})
			Ω(err).Should(MatchError("missing application name"))

			name, err = callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv", "APP_NAME"})
			Ω(err).ShouldNot(HaveOccurred())
			Ω(name).Should(Equal("APP_NAME"))
		})

		It("Retrieve Application Environment Variables From Name", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"SOME", "OUTPUT", "COMMAND"}, nil)
开发者ID:Samze,项目名称:copyenv,代码行数:31,代码来源:copyenv_test.go


示例18:

package cfcurl_test

import (
	"bufio"
	"errors"
	"os"

	. "github.com/krujos/cfcurl"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cfcurl", func() {
	var fakeCliConnection *fakes.FakeCliConnection

	Describe("an api that is not depricated", func() {
		var v2apps []string

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			file, err := os.Open("apps.json")
			defer file.Close()
			if err != nil {
				Fail("Could not open apps.json")
			}

			scanner := bufio.NewScanner(file)
			for scanner.Scan() {
				v2apps = append(v2apps, scanner.Text())
开发者ID:krujos,项目名称:cfcurl,代码行数:31,代码来源:cfcurl_test.go


示例19:

import (
	"bytes"
	"errors"
	"strings"

	. "github.com/bluemixgaragelondon/cf-blue-green-deploy"
	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("BlueGreenDeploy", func() {
	var (
		bgdExitsWithErrors []error
		bgdOut             *bytes.Buffer
		connection         *fakes.FakeCliConnection
		p                  BlueGreenDeploy
		testErrorFunc      func(message string, err error)
	)

	BeforeEach(func() {
		bgdExitsWithErrors = []error{}
		testErrorFunc = func(message string, err error) {
			bgdExitsWithErrors = append(bgdExitsWithErrors, err)
		}
		bgdOut = &bytes.Buffer{}

		connection = &fakes.FakeCliConnection{}
		p = BlueGreenDeploy{Connection: connection, ErrorFunc: testErrorFunc, Out: bgdOut}
	})
开发者ID:gerhard,项目名称:cf-blue-green-deploy,代码行数:30,代码来源:blue_green_deploy_test.go


示例20:

package application_repo_test

import (
	"errors"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/xchapter7x/autopilot/application_repo"
)

var _ = Describe("ApplicationRepo", func() {
	var (
		cliConn *fakes.FakeCliConnection
		repo    *ApplicationRepo
	)

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		repo = NewApplicationRepo(cliConn)
	})

	Describe("RenameApplication", func() {
		It("renames the application", func() {
			err := repo.RenameApplication("old-name", "new-name")
			Ω(err).ShouldNot(HaveOccurred())

			Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
			args := cliConn.CliCommandArgsForCall(0)
			Ω(args).Should(Equal([]string{"rename", "old-name", "new-name"}))
		})
开发者ID:xchapter7x,项目名称:autopilot,代码行数:31,代码来源:application_repo_test.go



注:本文中的github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang rpc.NewNonCodegangstaRunner函数代码示例发布时间:2022-05-23
下一篇:
Golang plugin.CliConnection类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap