예제 #1
0
파일: fake_pwd_repo.go 프로젝트: jbayer/cli
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
}
예제 #2
0
파일: fake_app_repo.go 프로젝트: jbayer/cli
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
}
예제 #3
0
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
}
예제 #4
0
파일: fake_app_repo.go 프로젝트: jbayer/cli
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
}