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 := controller.NewUseEnvironmentCommandForTest(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) } } }
func (s *UseEnvironmentSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { wrappedCommand, _ := controller.NewUseEnvironmentCommandForTest(s.api, &s.creds, &s.endpoint) return testing.RunCommand(c, wrappedCommand, args...) }