Beispiel #1
0
func (s *CredentialsCommandSuite) TestInit(c *gc.C) {
	for i, test := range []struct {
		args        []string
		outPath     string
		errorString string
	}{
		{
		// no args is fine
		}, {
			args:    []string{"--output=foo.bar"},
			outPath: "foo.bar",
		}, {
			args:    []string{"-o", "foo.bar"},
			outPath: "foo.bar",
		}, {
			args:        []string{"foobar"},
			errorString: `unrecognized args: \["foobar"\]`,
		},
	} {
		c.Logf("test %d", i)
		wrappedCommand, command := user.NewCredentialsCommandForTest()
		err := testing.InitCommand(wrappedCommand, test.args)
		if test.errorString == "" {
			c.Check(command.OutPath, gc.Equals, test.outPath)
		} else {
			c.Check(err, gc.ErrorMatches, test.errorString)
		}
	}
}
Beispiel #2
0
func (s *CredentialsCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	wrappedCommand, _ := user.NewCredentialsCommandForTest()
	return testing.RunCommand(c, wrappedCommand, args...)
}