当前位置: 首页>>代码示例>>Golang>>正文


Golang Config.SetLogin方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/ltc/config.Config.SetLogin方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.SetLogin方法的具体用法?Golang Config.SetLogin怎么用?Golang Config.SetLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/ltc/config.Config的用法示例。


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

示例1:

	Describe("TargetCommand", func() {
		var targetCommand cli.Command

		verifyOldTargetStillSet := func() {
			newConfig := config_package.New(configPersister)
			Expect(newConfig.Load()).To(Succeed())

			Expect(newConfig.Receptor()).To(Equal("http://olduser:[email protected]"))
		}

		BeforeEach(func() {
			commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeBlobStoreVerifier, fakeExitHandler, fakeVersionManager)
			targetCommand = commandFactory.MakeTargetCommand()

			config.SetTarget("oldtarget.com")
			config.SetLogin("olduser", "oldpass")
			Expect(config.Save()).To(Succeed())
		})

		Context("displaying the target", func() {
			JustBeforeEach(func() {
				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{})
			})

			It("outputs the current user and target host", func() {
				Expect(outputBuffer).To(test_helpers.SayLine("Target:\t\[email protected]"))
			})

			Context("when no username is set", func() {
				BeforeEach(func() {
					config.SetLogin("", "")
开发者ID:davidwadden,项目名称:ltc,代码行数:31,代码来源:config_command_factory_test.go

示例2:

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

var _ = Describe("AppDialer", func() {
	Describe("#Dial", func() {
		var (
			origDial func(network, addr string, config *ssh.ClientConfig) (*ssh.Client, error)
			config   *config_package.Config
		)

		BeforeEach(func() {
			config = config_package.New(nil)
			config.SetTarget("some-host")
			config.SetLogin("some-user", "some-password")
			origDial = sshapi.DialFunc
		})

		AfterEach(func() {
			sshapi.DialFunc = origDial
		})

		It("should create a client", func() {
			dialCalled := false
			sshClient := &ssh.Client{}

			sshapi.DialFunc = func(network, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
				Expect(network).To(Equal("tcp"))
				Expect(addr).To(Equal("some-host:2222"))
				Expect(config.User).To(Equal("diego:some-app-name/100"))
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:30,代码来源:dialer_test.go

示例3:

	BeforeEach(func() {
		testPersister = &fakePersister{}
		testConfig = config.New(testPersister)
	})

	Describe("Target", func() {
		It("sets the target", func() {
			testConfig.SetTarget("mynewapi.com")

			Expect(testConfig.Target()).To(Equal("mynewapi.com"))
		})
	})

	Describe("Username", func() {
		It("sets the target", func() {
			testConfig.SetLogin("ausername", "apassword")

			Expect(testConfig.Username()).To(Equal("ausername"))
		})
	})

	Describe("Receptor", func() {
		It("returns the Receptor with a username and password", func() {
			testConfig.SetTarget("mynewapi.com")
			testConfig.SetLogin("testusername", "testpassword")

			Expect(testConfig.Receptor()).To(Equal("http://testusername:[email protected]"))
		})

		It("returns a Receptor without a username and password", func() {
			testConfig.SetTarget("mynewapi.com")
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:31,代码来源:config_test.go


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