func (s *RemoveUserCommandSuite) TestInit(c *gc.C) { table := []struct { args []string confirm bool errorString string }{{ confirm: false, errorString: "no username supplied", }, { args: []string{"--yes"}, confirm: true, errorString: "no username supplied", }, { args: []string{"--yes", "jjam"}, confirm: true, }} for _, test := range table { wrappedCommand, command := user.NewRemoveCommandForTest(s.mockAPI, s.store) err := testing.InitCommand(wrappedCommand, test.args) c.Check(command.ConfirmDelete, jc.DeepEquals, test.confirm) if test.errorString == "" { c.Check(err, jc.ErrorIsNil) } else { c.Check(err, gc.ErrorMatches, test.errorString) } } }
func (s *RemoveUserCommandSuite) TestRemove(c *gc.C) { username := "******" command, _ := user.NewRemoveCommandForTest(s.mockAPI, s.store) _, err := testing.RunCommand(c, command, "-y", username) c.Assert(err, jc.ErrorIsNil) c.Assert(s.mockAPI.username, gc.Equals, username) }
func (s *RemoveUserCommandSuite) TestRemovePrompts(c *gc.C) { username := "******" expected := ` WARNING! This command will remove the user "testing" from the "testing" controller. Continue (y/N)? `[1:] command, _ := user.NewRemoveCommandForTest(s.mockAPI, s.store) ctx, _ := testing.RunCommand(c, command, username) c.Assert(testing.Stdout(ctx), jc.DeepEquals, expected) }
func (s *RemoveUserCommandSuite) run(c *gc.C, name string) (*cmd.Context, error) { removeCommand, _ := user.NewRemoveCommandForTest(s.mockAPI, s.store) return testing.RunCommand(c, removeCommand, name) }