예제 #1
0
func TestCreateSpaceInOrg(t *testing.T) {
	resetSpaceDefaults()

	defaultOrgRepo.FindByNameOrganization = maker.NewOrg(maker.Overrides{
		"name": "other-org",
	})

	ui := callCreateSpace(t, []string{"-o", "other-org", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating space", "my-space", "other-org", "my-user"},
		{"OK"},
		{"Assigning", "my-user", "my-space", cf.SpaceRoleToUserInput[cf.SPACE_MANAGER]},
		{"Assigning", "my-user", "my-space", cf.SpaceRoleToUserInput[cf.SPACE_DEVELOPER]},
		{"TIP"},
	})

	assert.Equal(t, defaultSpaceRepo.CreateSpaceName, "my-space")
	assert.Equal(t, defaultSpaceRepo.CreateSpaceOrgGuid, defaultOrgRepo.FindByNameOrganization.Guid)
	assert.Equal(t, defaultUserRepo.SetSpaceRoleUserGuid, "my-user-guid")
	assert.Equal(t, defaultUserRepo.SetSpaceRoleSpaceGuid, "my-space-guid")
	assert.Equal(t, defaultUserRepo.SetSpaceRoleRole, cf.SPACE_DEVELOPER)
}
예제 #2
0
			{"Assigning", "my-user", "my-space", models.SpaceRoleToUserInput[models.SPACE_MANAGER]},
			{"Assigning", "my-user", "my-space", models.SpaceRoleToUserInput[models.SPACE_DEVELOPER]},
			{"TIP"},
		})

		Expect(defaultSpaceRepo.CreateSpaceName).To(Equal("my-space"))
		Expect(defaultSpaceRepo.CreateSpaceOrgGuid).To(Equal("my-org-guid"))
		Expect(defaultUserRepo.SetSpaceRoleUserGuid).To(Equal("my-user-guid"))
		Expect(defaultUserRepo.SetSpaceRoleSpaceGuid).To(Equal("my-space-guid"))
		Expect(defaultUserRepo.SetSpaceRoleRole).To(Equal(models.SPACE_DEVELOPER))
	})
	It("TestCreateSpaceInOrg", func() {

		resetSpaceDefaults()

		org := maker.NewOrg(maker.Overrides{"name": "other-org"})
		defaultOrgRepo.Organizations = []models.Organization{org}

		ui := callCreateSpace([]string{"-o", "other-org", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Creating space", "my-space", "other-org", "my-user"},
			{"OK"},
			{"Assigning", "my-user", "my-space", models.SpaceRoleToUserInput[models.SPACE_MANAGER]},
			{"Assigning", "my-user", "my-space", models.SpaceRoleToUserInput[models.SPACE_DEVELOPER]},
			{"TIP"},
		})

		Expect(defaultSpaceRepo.CreateSpaceName).To(Equal("my-space"))
		Expect(defaultSpaceRepo.CreateSpaceOrgGuid).To(Equal(org.Guid))
		Expect(defaultUserRepo.SetSpaceRoleUserGuid).To(Equal("my-user-guid"))
예제 #3
0
		Expect(c.Config.OrganizationFields().Guid).To(Equal("my-org-guid"))
		Expect(c.Config.SpaceFields().Guid).To(BeEmpty())
		Expect(c.Config.AccessToken()).To(Equal("my_access_token"))
		Expect(c.Config.RefreshToken()).To(Equal("my_refresh_token"))

		testassert.SliceContains(c.ui.Outputs, testassert.Lines{
			{"Failed"},
		})
	})

	It("TestSuccessfullyLoggingInWithoutTargetOrg", func() {
		c := setUpLoginTestContext()

		c.ui.Inputs = []string{"api.example.com", "*****@*****.**", "password", ""}

		org1 := maker.NewOrg(maker.Overrides{"name": "org1"})
		org2 := maker.NewOrg(maker.Overrides{"name": "org2"})
		c.orgRepo.Organizations = []models.Organization{org1, org2}

		callLogin(c)

		testassert.SliceContains(c.ui.Outputs, testassert.Lines{
			{"Select an org (or press enter to skip):"},
		})
		testassert.SliceDoesNotContain(c.ui.Outputs, testassert.Lines{
			{"Select a space", "or press enter to skip"},
		})
		Expect(c.Config.ApiEndpoint()).To(Equal("api.example.com"))
		Expect(c.Config.OrganizationFields().Guid).To(Equal(""))
		Expect(c.Config.SpaceFields().Guid).To(Equal(""))
		Expect(c.Config.AccessToken()).To(Equal("my_access_token"))