本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/config.Config.SetLogin方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.SetLogin方法的具体用法?Golang Config.SetLogin怎么用?Golang Config.SetLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/lattice/ltc/config.Config
的用法示例。
在下文中一共展示了Config.SetLogin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
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("", "")
示例2:
oldTerm string
)
BeforeEach(func() {
fakeDialer = &fake_dialer.FakeDialer{}
fakeSession = &fake_secure_session.FakeSecureSession{}
fakeTerm = &fake_term.FakeTerm{}
fakeStdin = gbytes.NewBuffer()
fakeStdout = gbytes.NewBuffer()
fakeStderr = gbytes.NewBuffer()
fakeClock = fakeclock.NewFakeClock(time.Now())
config = config_package.New(nil)
config.SetTarget("10.0.12.34")
config.SetLogin("user", "past")
secureShell = &secure_shell.SecureShell{
Dialer: fakeDialer,
Term: fakeTerm,
Clock: fakeClock,
Ticker: fakeclock.NewFakeTicker(fakeClock, 1*time.Second),
}
fakeDialer.DialReturns(fakeSession, nil)
oldTerm = os.Getenv("TERM")
os.Setenv("TERM", "defaultterm")
})
AfterEach(func() {
os.Setenv("TERM", oldTerm)
示例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")
示例4:
. "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"))