示例#1
0
func (s *shareSuite) TestInit(c *gc.C) {
	wrappedCmd, shareCmd := model.NewShareCommandForTest(s.fake)
	err := testing.InitCommand(wrappedCmd, []string{})
	c.Assert(err, gc.ErrorMatches, "no users specified")

	err = testing.InitCommand(wrappedCmd, []string{"bob@local", "sam"})
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(shareCmd.Users[0], gc.Equals, names.NewUserTag("bob@local"))
	c.Assert(shareCmd.Users[1], gc.Equals, names.NewUserTag("sam"))

	err = testing.InitCommand(wrappedCmd, []string{"not valid/0"})
	c.Assert(err, gc.ErrorMatches, `invalid username: "******"`)
}
示例#2
0
func (s *shareSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command, _ := model.NewShareCommandForTest(s.fake)
	return testing.RunCommand(c, command, args...)
}