Beispiel #1
0
func (repo *FakeBuildpackRepository) Create(newBuildpack cf.Buildpack) (cf.Buildpack, net.ApiResponse) {
	if repo.CreateBuildpackExists {
		return repo.CreateBuildpack, net.NewApiResponse("Buildpack already exists", cf.BUILDPACK_EXISTS, 400)
	}

	return repo.CreateBuildpack, repo.CreateApiResponse
}
Beispiel #2
0
func (repo *FakeOrgRepository) Create(name string) (apiResponse net.ApiResponse) {
	if repo.CreateOrgExists {
		apiResponse = net.NewApiResponse("Space already exists", cf.ORG_EXISTS, 400)
		return
	}
	repo.CreateName = name
	return
}
Beispiel #3
0
func (repo *FakeBuildpackRepository) Create(name string, position *int, enabled *bool) (createdBuildpack cf.Buildpack, apiResponse net.ApiResponse) {
	if repo.CreateBuildpackExists {
		return repo.CreateBuildpack, net.NewApiResponse("Buildpack already exists", cf.BUILDPACK_EXISTS, 400)
	}

	repo.CreateBuildpack = cf.Buildpack{BasicFields: cf.BasicFields{Name: name}, Position: position, Enabled: enabled}
	return repo.CreateBuildpack, repo.CreateApiResponse
}
func (repo *FakeBuildpackRepository) Create(name string, position *int, enabled *bool, locked *bool) (createdBuildpack models.Buildpack, apiResponse net.ApiResponse) {
	if repo.CreateBuildpackExists {
		return repo.CreateBuildpack, net.NewApiResponse("Buildpack already exists", cf.BUILDPACK_EXISTS, 400)
	}

	repo.CreateBuildpack = models.Buildpack{Name: name, Position: position, Enabled: enabled, Locked: locked}
	return repo.CreateBuildpack, repo.CreateApiResponse
}
Beispiel #5
0
func (repo *FakeUserRepository) Create(user cf.User) (apiResponse net.ApiResponse) {
	repo.CreateUserUser = user

	if repo.CreateUserExists {
		apiResponse = net.NewApiResponse("User already exists", cf.USER_EXISTS, 400)
	}

	return
}
Beispiel #6
0
func (repo *FakeUserRepository) Create(username, password string) (apiResponse net.ApiResponse) {
	repo.CreateUserUsername = username
	repo.CreateUserPassword = password

	if repo.CreateUserExists {
		apiResponse = net.NewApiResponse("UserFields already exists", cf.USER_EXISTS, 400)
	}

	return
}
func (repo *FakeServiceBindingRepo) Create(instanceGuid, appGuid string) (apiResponse net.ApiResponse) {
	repo.CreateServiceInstanceGuid = instanceGuid
	repo.CreateApplicationGuid = appGuid

	if repo.CreateErrorCode != "" {
		apiResponse = net.NewApiResponse("Error binding service", repo.CreateErrorCode, http.StatusBadRequest)
	}

	return
}
Beispiel #8
0
func (repo *FakeAppSummaryRepo) GetSummary(app cf.Application) (summary cf.AppSummary, apiResponse net.ApiResponse) {
	repo.GetSummaryApp = app
	summary = repo.GetSummarySummary

	if repo.GetSummaryErrorCode != "" {
		apiResponse = net.NewApiResponse("Error", repo.GetSummaryErrorCode, http.StatusBadRequest)
	}

	return
}
Beispiel #9
0
func (repo *FakePasswordRepo) UpdatePassword(old string, new string) (apiResponse net.ApiResponse) {
	repo.UpdateOldPassword = old
	repo.UpdateNewPassword = new

	if repo.UpdateUnauthorized {
		apiResponse = net.NewApiResponse("Authorization Failed", "unauthorized", 401)
	}

	return
}
Beispiel #10
0
func (repo *FakeSpaceRepository) Create(name string, orgGuid string) (space cf.Space, apiResponse net.ApiResponse) {
	if repo.CreateSpaceExists {
		apiResponse = net.NewApiResponse("Space already exists", cf.SPACE_EXISTS, 400)
		return
	}
	repo.CreateSpaceName = name
	repo.CreateSpaceOrgGuid = orgGuid
	space = repo.CreateSpaceSpace
	return
}
func (repo *FakeAppSummaryRepo) GetSummary(appGuid string) (summary models.AppSummary, apiResponse net.ApiResponse) {
	repo.GetSummaryAppGuid = appGuid
	summary = repo.GetSummarySummary

	if repo.GetSummaryErrorCode != "" {
		apiResponse = net.NewApiResponse("Error", repo.GetSummaryErrorCode, http.StatusBadRequest)
	}

	return
}
func (repo *FakeServiceBindingRepo) Create(instance cf.ServiceInstance, app cf.Application) (apiResponse net.ApiResponse) {
	repo.CreateServiceInstance = instance
	repo.CreateApplication = app

	if repo.CreateErrorCode != "" {
		apiResponse = net.NewApiResponse("Error binding service", repo.CreateErrorCode, http.StatusBadRequest)
	}

	return
}
Beispiel #13
0
func (repo *FakeApplicationRepository) GetInstances(app cf.Application) (instances []cf.ApplicationInstance, apiResponse net.ApiResponse) {
	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 != "" {
		apiResponse = net.NewApiResponse("Error staging app", errorCode, http.StatusBadRequest)
		return
	}

	return
}
Beispiel #14
0
func (repo *FakeApplicationRepository) Read(name string) (app models.Application, apiResponse net.ApiResponse) {
	repo.ReadName = name
	app = repo.ReadApp

	if repo.ReadErr {
		apiResponse = net.NewApiResponseWithMessage("Error finding app by name.")
	}
	if repo.ReadAuthErr {
		apiResponse = net.NewApiResponse("Authentication failed.", "1000", 401)
	}
	if repo.ReadNotFound {
		apiResponse = net.NewNotFoundApiResponse("%s %s not found", "App", name)
	}

	return
}
func (repo *FakeAppInstancesRepo) GetInstances(appGuid string) (instances []models.AppInstanceFields, apiResponse net.ApiResponse) {
	repo.GetInstancesAppGuid = appGuid
	time.Sleep(1 * time.Millisecond) //needed for Windows only, otherwise it thinks error codes are not assigned

	if len(repo.GetInstancesResponses) > 0 {
		instances = repo.GetInstancesResponses[0]
		repo.GetInstancesResponses = repo.GetInstancesResponses[1:]
	}

	if len(repo.GetInstancesErrorCodes) > 0 {
		errorCode := repo.GetInstancesErrorCodes[0]
		repo.GetInstancesErrorCodes = repo.GetInstancesErrorCodes[1:]
		if errorCode != "" {
			apiResponse = net.NewApiResponse("Error staging app", errorCode, http.StatusBadRequest)
		}
	}

	return
}