Beispiel #1
0
func TestDeleteServiceWithServiceBindings(t *testing.T) {
	_, _, repo := createServiceRepo(t, []testnet.TestRequest{})

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	binding := cf.ServiceBindingFields{}
	binding.Url = "/v2/service_bindings/service-binding-1-guid"
	binding.AppGuid = "app-1-guid"

	binding2 := cf.ServiceBindingFields{}
	binding2.Url = "/v2/service_bindings/service-binding-2-guid"
	binding2.AppGuid = "app-2-guid"

	serviceInstance.ServiceBindings = []cf.ServiceBindingFields{binding, binding2}

	apiResponse := repo.DeleteService(serviceInstance)
	assert.True(t, apiResponse.IsNotSuccessful())
	assert.Equal(t, apiResponse.Message, "Cannot delete service instance, apps are still bound to it")
}
Beispiel #2
0
func TestDeleteServiceBinding(t *testing.T) {
	ts, handler, repo := createServiceBindingRepo(t, []testnet.TestRequest{deleteBindingReq})
	defer ts.Close()

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	binding := cf.ServiceBindingFields{}
	binding.Url = "/v2/service_bindings/service-binding-1-guid"
	binding.AppGuid = "app-1-guid"
	binding2 := cf.ServiceBindingFields{}
	binding2.Url = "/v2/service_bindings/service-binding-2-guid"
	binding2.AppGuid = "app-2-guid"
	serviceInstance.ServiceBindings = []cf.ServiceBindingFields{binding, binding2}

	found, apiResponse := repo.Delete(serviceInstance, "app-2-guid")

	assert.True(t, handler.AllRequestsCalled())
	assert.False(t, apiResponse.IsNotSuccessful())
	assert.True(t, found)
}