コード例 #1
0
ファイル: fake_buildpack_repo.go プロジェクト: jalateras/cli
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
}
コード例 #2
0
ファイル: fake_org_repo.go プロジェクト: normalnorman/cli
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
}
コード例 #3
0
ファイル: fake_buildpack_repo.go プロジェクト: nsnt/cli
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
}
コード例 #4
0
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
}
コード例 #5
0
ファイル: fake_user_repo.go プロジェクト: jalateras/cli
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
}
コード例 #6
0
ファイル: fake_user_repo.go プロジェクト: nsnt/cli
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
}
コード例 #7
0
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
}
コード例 #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
}
コード例 #9
0
ファイル: fake_pwd_repo.go プロジェクト: nsnt/cli
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
}
コード例 #10
0
ファイル: fake_space_repo.go プロジェクト: nsnt/cli
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
}
コード例 #11
0
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
}
コード例 #12
0
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
}
コード例 #13
0
ファイル: fake_app_repo.go プロジェクト: jalateras/cli
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
}
コード例 #14
0
ファイル: fake_app_repo.go プロジェクト: normalnorman/cli
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
}
コード例 #15
0
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
}