예제 #1
0
func (s *UseEnvironmentSuite) TestInit(c *gc.C) {
	for i, test := range []struct {
		args        []string
		errorString string
		localName   string
		owner       string
		envName     string
		envUUID     string
	}{{
		errorString: "no environment supplied",
	}, {
		args:        []string{""},
		errorString: "no environment supplied",
	}, {
		args:    []string{"env-name"},
		envName: "env-name",
	}, {
		args:      []string{"env-name", "--name", "foo"},
		localName: "foo",
		envName:   "env-name",
	}, {
		args:    []string{"user/foobar"},
		envName: "foobar",
		owner:   "user",
	}, {
		args:    []string{"user@local/foobar"},
		envName: "foobar",
		owner:   "user@local",
	}, {
		args:    []string{"user@remote/foobar"},
		envName: "foobar",
		owner:   "user@remote",
	}, {
		args:        []string{"+user+name/foobar"},
		errorString: `"\+user\+name" is not a valid user`,
	}, {
		args:    []string{env1UUID},
		envUUID: env1UUID,
	}, {
		args:    []string{"user/" + env1UUID},
		owner:   "user",
		envUUID: env1UUID,
	}} {
		c.Logf("test %d", i)
		wrappedCommand, command := system.NewUseEnvironmentCommand(nil, nil, nil)
		err := testing.InitCommand(wrappedCommand, test.args)
		if test.errorString == "" {
			c.Check(command.LocalName, gc.Equals, test.localName)
			c.Check(command.EnvName, gc.Equals, test.envName)
			c.Check(command.EnvUUID, gc.Equals, test.envUUID)
			c.Check(command.Owner, gc.Equals, test.owner)
		} else {
			c.Check(err, gc.ErrorMatches, test.errorString)
		}
	}
}
예제 #2
0
func (s *UseEnvironmentSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	wrappedCommand, _ := system.NewUseEnvironmentCommand(s.api, &s.creds, &s.endpoint)
	return testing.RunCommand(c, wrappedCommand, args...)
}
예제 #3
0
func (s *UseEnvironmentSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command := system.NewUseEnvironmentCommand(s.api, &s.creds, &s.endpoint)
	return testing.RunCommand(c, envcmd.WrapSystem(command), args...)
}