func (repo *FakePasswordRepo) UpdatePassword(old string, new string) (apiErr *net.ApiError) { repo.UpdateOldPassword = old repo.UpdateNewPassword = new if repo.UpdateUnauthorized { apiErr = net.NewApiError("Authorization Failed", "unauthorized", 401) } return }
func (repo *FakeApplicationRepository) FindByName(name string) (app cf.Application, apiErr *net.ApiError) { repo.AppName = name if repo.AppByNameErr { apiErr = net.NewApiErrorWithMessage("Error finding app by name.") } if repo.AppByNameAuthErr { apiErr = net.NewApiError("Authentication failed.", "1000", 401) } return repo.AppByName, apiErr }
func (repo *FakeServiceRepo) BindService(instance cf.ServiceInstance, app cf.Application) (apiErr *net.ApiError) { repo.BindServiceServiceInstance = instance repo.BindServiceApplication = app if repo.BindServiceErrorCode != "" { apiErr = net.NewApiError("Error binding service", repo.BindServiceErrorCode, http.StatusBadRequest) } return }
func (repo *FakeApplicationRepository) GetInstances(app cf.Application) (instances []cf.ApplicationInstance, apiErr *net.ApiError) { time.Sleep(1 * time.Millisecond) //needed for Windows only, otherwise it thinks error codes are not assigned errorCode := repo.GetInstancesErrorCodes[0] repo.GetInstancesErrorCodes = repo.GetInstancesErrorCodes[1:] instances = repo.GetInstancesResponses[0] repo.GetInstancesResponses = repo.GetInstancesResponses[1:] if errorCode != "" { apiErr = net.NewApiError("Error staging app", errorCode, http.StatusBadRequest) return } return }