コード例 #1
0
ファイル: set_test.go プロジェクト: imoapps/juju
func (s *SetSuite) assertSetWarning(c *gc.C, dir string, args []string, w string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Equals, 0)

	c.Assert(strings.Replace(c.GetTestLog(), "\n", " ", -1), gc.Matches, ".*WARNING.*"+w+".*")
}
コード例 #2
0
ファイル: set_test.go プロジェクト: imoapps/juju
func (s *SetSuite) TestSetCommandInit(c *gc.C) {
	// missing args
	err := coretesting.InitCommand(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), []string{})
	c.Assert(err, gc.ErrorMatches, "no service name specified")

	// missing service name
	err = coretesting.InitCommand(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), []string{"name=foo"})
	c.Assert(err, gc.ErrorMatches, "no service name specified")

	// --config path, but no service
	err = coretesting.InitCommand(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), []string{"--config", "testconfig.yaml"})
	c.Assert(err, gc.ErrorMatches, "no service name specified")

	// --config and options specified
	err = coretesting.InitCommand(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), []string{"service", "--config", "testconfig.yaml", "bees="})
	c.Assert(err, gc.ErrorMatches, "cannot specify --config when using key=value arguments")
}
コード例 #3
0
ファイル: set_test.go プロジェクト: imoapps/juju
func (s *SetSuite) TestBlockSetConfig(c *gc.C) {
	// Block operation
	s.fakeServiceAPI.err = common.OperationBlockedError("TestBlockSetConfig")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, []string{
		"dummy-service",
		"--config",
		"testconfig.yaml"})
	c.Check(code, gc.Equals, 1)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockSetConfig.*")
}
コード例 #4
0
ファイル: set_test.go プロジェクト: imoapps/juju
func (s *SetSuite) TestSetConfig(c *gc.C) {
	s.assertSetFail(c, s.dir, []string{
		"--config",
		"missing.yaml",
	}, "error.* "+utils.NoSuchFileErrRegexp+"\n")

	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, []string{
		"dummy-service",
		"--config",
		"testconfig.yaml"})

	c.Check(code, gc.Equals, 0)
	c.Check(s.fakeServiceAPI.config, gc.Equals, yamlConfigValue)
}
コード例 #5
0
ファイル: set_test.go プロジェクト: imoapps/juju
// assertSetFail sets configuration options and checks the expected error.
func (s *SetSuite) assertSetFail(c *gc.C, dir string, args []string, err string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Not(gc.Equals), 0)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Matches, err)
}
コード例 #6
0
ファイル: set_test.go プロジェクト: imoapps/juju
// assertSetSuccess sets configuration options and checks the expected settings.
func (s *SetSuite) assertSetSuccess(c *gc.C, dir string, args []string, expect map[string]interface{}) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Equals, 0)
	c.Assert(s.fakeClientAPI.values, gc.DeepEquals, expect)
}