Example #1
0
		space.Name = "some-space"
		space.Guid = "some-space-guid"
		spaceRepo.FindByNameInOrgReturns(space, nil)

		args := []string{"my-username", "my-org", "my-space", "SpaceManager"}

		ui, _ := callUnsetSpaceRole(args, spaceRepo, userRepo, requirementsFactory)

		actualSpaceName, actualOrgGUID := spaceRepo.FindByNameInOrgArgsForCall(0)
		Expect(actualSpaceName).To(Equal("my-space"))
		Expect(actualOrgGUID).To(Equal("some-org-guid"))

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"Removing role", "SpaceManager", "some-user", "some-org", "some-space", "my-user"},
			[]string{"OK"},
		))

		userGUID, spaceGUID, role := userRepo.UnsetSpaceRoleArgsForCall(0)
		Expect(role).To(Equal(models.SPACE_MANAGER))
		Expect(userGUID).To(Equal("some-user-guid"))
		Expect(spaceGUID).To(Equal("some-space-guid"))
	})
})

func getUnsetSpaceRoleDeps() (requirementsFactory *testreq.FakeReqFactory, spaceRepo *testapi.FakeSpaceRepository, userRepo *testapi.FakeUserRepository) {
	requirementsFactory = &testreq.FakeReqFactory{}
	spaceRepo = &testapi.FakeSpaceRepository{}
	userRepo = &testapi.FakeUserRepository{}
	return
}