예제 #1
0
파일: delete_org_test.go 프로젝트: nsnt/cli
func TestDeleteTargetedOrganizationClearsConfig(t *testing.T) {
	configRepo := &testconfig.FakeConfigRepository{}
	config, _ := configRepo.Get()

	organizationFields := cf.OrganizationFields{}
	organizationFields.Name = "org-to-delete"
	organizationFields.Guid = "org-to-delete-guid"
	config.OrganizationFields = organizationFields

	spaceFields := cf.SpaceFields{}
	spaceFields.Name = "space-to-delete"
	config.SpaceFields = spaceFields
	configRepo.Save()

	org := cf.Organization{}
	org.OrganizationFields = organizationFields
	orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
	deleteOrg(t, "Yes", []string{"org-to-delete"}, orgRepo)

	updatedConfig, err := configRepo.Get()
	assert.NoError(t, err)

	assert.Equal(t, updatedConfig.OrganizationFields, cf.OrganizationFields{})
	assert.Equal(t, updatedConfig.SpaceFields, cf.SpaceFields{})
}