本文整理汇总了Golang中github.com/juju/juju/cmd/envcmd.WriteCurrentSystem函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteCurrentSystem函数的具体用法?Golang WriteCurrentSystem怎么用?Golang WriteCurrentSystem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WriteCurrentSystem函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *EnvironmentsSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
err := envcmd.WriteCurrentSystem("fake")
c.Assert(err, jc.ErrorIsNil)
last1 := time.Date(2015, 3, 20, 0, 0, 0, 0, time.UTC)
last2 := time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC)
envs := []base.UserEnvironment{
{
Name: "test-env1",
Owner: "[email protected]",
UUID: "test-env1-UUID",
LastConnection: &last1,
}, {
Name: "test-env2",
Owner: "[email protected]",
UUID: "test-env2-UUID",
LastConnection: &last2,
}, {
Name: "test-env3",
Owner: "[email protected]",
UUID: "test-env3-UUID",
},
}
s.api = &fakeEnvMgrAPIClient{envs: envs}
s.creds = &configstore.APICredentials{User: "[email protected]", Password: "password"}
}
开发者ID:snailwalker,项目名称:juju,代码行数:29,代码来源:environments_test.go
示例2: TestWriteSystemRemovesEnvironmentFile
func (s *filesSuite) TestWriteSystemRemovesEnvironmentFile(c *gc.C) {
err := envcmd.WriteCurrentEnvironment("fubar")
c.Assert(err, jc.ErrorIsNil)
err = envcmd.WriteCurrentSystem("baz")
c.Assert(err, jc.ErrorIsNil)
c.Assert(envcmd.GetCurrentEnvironmentFilePath(), jc.DoesNotExist)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:files_test.go
示例3: TestWriteSystemAddsNewline
func (s *filesSuite) TestWriteSystemAddsNewline(c *gc.C) {
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
current, err := ioutil.ReadFile(envcmd.GetCurrentSystemFilePath())
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(current), gc.Equals, "fubar\n")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:files_test.go
示例4: TestEnvironCommandInitSystemFile
func (s *EnvironmentCommandSuite) TestEnvironCommandInitSystemFile(c *gc.C) {
// If there is a current-system file, error raised.
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
_, err = initTestCommand(c)
c.Assert(err, gc.ErrorMatches, `not operating on an environment, using system "fubar"`)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:environmentcommand_test.go
示例5: TestCurrentSystemHasPrecedence
func (s *SwitchSimpleSuite) TestCurrentSystemHasPrecedence(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
envcmd.WriteCurrentSystem("fubar")
context, err := testing.RunCommand(c, &SwitchCommand{})
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar (system)\n")
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:switch_test.go
示例6: SetUpTest
func (s *BaseSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
memstore := configstore.NewMem()
s.PatchValue(&configstore.Default, func() (configstore.Storage, error) {
return memstore, nil
})
os.Setenv(osenv.JujuEnvEnvKey, "testing")
info := memstore.CreateInfo("testing")
info.SetBootstrapConfig(map[string]interface{}{"random": "extra data"})
info.SetAPIEndpoint(configstore.APIEndpoint{
Addresses: []string{"127.0.0.1:12345"},
Hostnames: []string{"localhost:12345"},
CACert: testing.CACert,
EnvironUUID: "env-uuid",
})
info.SetAPICredentials(configstore.APICredentials{
User: "user-test",
Password: "password",
})
err := info.Write()
c.Assert(err, jc.ErrorIsNil)
s.PatchValue(user.ReadPassword, func() (string, error) {
return "sekrit", nil
})
err = envcmd.WriteCurrentSystem("testing")
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:27,代码来源:user_test.go
示例7: SetUpTest
func (s *removeBlocksSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
err := envcmd.WriteCurrentSystem("fake")
c.Assert(err, jc.ErrorIsNil)
s.api = &fakeRemoveBlocksAPI{}
}
开发者ID:snailwalker,项目名称:juju,代码行数:8,代码来源:removeblocks_test.go
示例8: TestCurrentCommenctionNameSystem
func (*filesSuite) TestCurrentCommenctionNameSystem(c *gc.C) {
err := envcmd.WriteCurrentSystem("baz")
c.Assert(err, jc.ErrorIsNil)
name, isSystem, err := envcmd.CurrentConnectionName()
c.Assert(err, jc.ErrorIsNil)
c.Assert(isSystem, jc.IsTrue)
c.Assert(name, gc.Equals, "baz")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:8,代码来源:files_test.go
示例9: TestSystemCommandInitExplicit
func (s *SystemCommandSuite) TestSystemCommandInitExplicit(c *gc.C) {
// Take system name from command line arg, and it trumps the current-
// system file.
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
testEnsureSystemName(c, "explicit", "-s", "explicit")
testEnsureSystemName(c, "explicit", "--system", "explicit")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:8,代码来源:systemcommand_test.go
示例10: TestSetCurrentSystemExistingSystem
func (s *filesSuite) TestSetCurrentSystemExistingSystem(c *gc.C) {
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
ctx := testing.Context(c)
err = envcmd.SetCurrentSystem(ctx, "new-sys")
c.Assert(err, jc.ErrorIsNil)
s.assertCurrentSystem(c, "new-sys")
c.Assert(testing.Stderr(ctx), gc.Equals, "fubar (system) -> new-sys (system)\n")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:9,代码来源:files_test.go
示例11: TestSystemEnvironmentsCommand
func (s *cmdSystemSuite) TestSystemEnvironmentsCommand(c *gc.C) {
c.Assert(envcmd.WriteCurrentSystem("dummyenv"), jc.ErrorIsNil)
s.createEnv(c, "new-env", false)
context := s.run(c, "environments")
c.Assert(testing.Stdout(context), gc.Equals, ""+
"NAME OWNER LAST CONNECTION\n"+
"dummyenv [email protected] just now\n"+
"new-env [email protected] never connected\n"+
"\n")
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:10,代码来源:cmd_juju_system_test.go
示例12: TestRemoveBlocks
func (s *cmdSystemSuite) TestRemoveBlocks(c *gc.C) {
c.Assert(envcmd.WriteCurrentSystem("dummyenv"), jc.ErrorIsNil)
s.State.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyEnvironment")
s.State.SwitchBlockOn(state.ChangeBlock, "TestChangeBlock")
s.run(c, "remove-blocks")
blocks, err := s.State.AllBlocksForSystem()
c.Assert(err, jc.ErrorIsNil)
c.Assert(blocks, gc.HasLen, 0)
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:11,代码来源:cmd_juju_system_test.go
示例13: TestListBlocks
func (s *cmdSystemSuite) TestListBlocks(c *gc.C) {
c.Assert(envcmd.WriteCurrentSystem("dummyenv"), jc.ErrorIsNil)
s.State.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyEnvironment")
s.State.SwitchBlockOn(state.ChangeBlock, "TestChangeBlock")
ctx := s.run(c, "list-blocks", "--format", "json")
expected := fmt.Sprintf(`[{"name":"dummyenv","env-uuid":"%s","owner-tag":"%s","blocks":["BlockDestroy","BlockChange"]}]`,
s.State.EnvironUUID(), s.AdminUserTag(c).String())
strippedOut := strings.Replace(testing.Stdout(ctx), "\n", "", -1)
c.Check(strippedOut, gc.Equals, expected)
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:12,代码来源:cmd_juju_system_test.go
示例14: TestCreateEnvironment
func (s *cmdSystemSuite) TestCreateEnvironment(c *gc.C) {
c.Assert(envcmd.WriteCurrentSystem("dummyenv"), jc.ErrorIsNil)
// The JujuConnSuite doesn't set up an ssh key in the fake home dir,
// so fake one on the command line. The dummy provider also expects
// a config value for 'state-server'.
context := s.run(c, "create-environment", "new-env", "authorized-keys=fake-key", "state-server=false")
c.Check(testing.Stdout(context), gc.Equals, "")
c.Check(testing.Stderr(context), gc.Equals, `
created environment "new-env"
dummyenv (system) -> new-env
`[1:])
// Make sure that the saved server details are sufficient to connect
// to the api server.
api, err := juju.NewAPIFromName("new-env")
c.Assert(err, jc.ErrorIsNil)
api.Close()
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:18,代码来源:cmd_juju_system_test.go
示例15: SetUpTest
func (s *UseEnvironmentSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
err := envcmd.WriteCurrentSystem("fake")
c.Assert(err, jc.ErrorIsNil)
envs := []base.UserEnvironment{{
Name: "unique",
Owner: "[email protected]",
UUID: "some-uuid",
}, {
Name: "test",
Owner: "[email protected]",
UUID: env1UUID,
}, {
Name: "test",
Owner: "[email protected]",
UUID: env2UUID,
}, {
Name: "other",
Owner: "[email protected]",
UUID: env3UUID,
}, {
Name: "other",
Owner: "[email protected]",
UUID: env4UUID,
}}
s.api = &fakeEnvMgrAPIClient{envs: envs}
s.creds = configstore.APICredentials{User: "tester", Password: "password"}
s.endpoint = configstore.APIEndpoint{
Addresses: []string{"127.0.0.1:12345"},
Hostnames: []string{"localhost:12345"},
CACert: testing.CACert,
ServerUUID: serverUUID,
}
}
开发者ID:snailwalker,项目名称:juju,代码行数:36,代码来源:useenvironment_test.go
示例16: TestSystemCommandInitSystemFile
func (s *SystemCommandSuite) TestSystemCommandInitSystemFile(c *gc.C) {
// If there is a current-system file, use that.
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
testEnsureSystemName(c, "fubar")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:6,代码来源:systemcommand_test.go
示例17: TestReadCurrentSystemSet
func (s *filesSuite) TestReadCurrentSystemSet(c *gc.C) {
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, jc.ErrorIsNil)
s.assertCurrentSystem(c, "fubar")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:5,代码来源:files_test.go
示例18: TestErrorWritingCurrentSystem
func (*filesSuite) TestErrorWritingCurrentSystem(c *gc.C) {
// Can't write a file over a directory.
os.MkdirAll(envcmd.GetCurrentSystemFilePath(), 0777)
err := envcmd.WriteCurrentSystem("fubar")
c.Assert(err, gc.ErrorMatches, "unable to write to the system file: .*")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:6,代码来源:files_test.go
注:本文中的github.com/juju/juju/cmd/envcmd.WriteCurrentSystem函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论