示例#1
0
		It("fails when not logged in", func() {
			requirementsFactory.LoginSuccess = false
			runCommand("my-user")
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})

		It("fails with usage when no arguments are given", func() {
			runCommand()
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Context("when the given user exists", func() {
		BeforeEach(func() {
			userRepo.FindByUsernameUserFields = models.UserFields{
				Username: "******",
				Guid:     "user-guid",
			}
		})

		It("deletes a user with the given name", func() {
			runCommand("user-name")

			Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the user user-name"}))

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Deleting user", "user-name", "admin-user"},
				[]string{"OK"},
			))

			Expect(userRepo.FindByUsernameUsername).To(Equal("user-name"))
			Expect(userRepo.DeleteUserGuid).To(Equal("user-guid"))