Ejemplo n.º 1
0
	It("creates a user", func() {
		runCommand("my-user", "my-password")

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"Creating user", "my-user"},
			[]string{"OK"},
			[]string{"TIP"},
		))

		Expect(userRepo.CreateUserUsername).To(Equal("my-user"))
	})

	Context("when creating the user returns an error", func() {
		It("prints a warning when the given user already exists", func() {
			userRepo.CreateUserExists = true

			runCommand("my-user", "my-password")

			Expect(ui.WarnOutputs).To(ContainSubstrings(
				[]string{"already exists"},
			))

			Expect(ui.Outputs).ToNot(ContainSubstrings([]string{"FAILED"}))
		})
		It("fails when any error other than alreadyExists is returned", func() {
			userRepo.CreateUserReturnsHttpError = true

			runCommand("my-user", "my-password")

			Expect(ui.Outputs).To(ContainSubstrings(