Skip to content

Commit

Permalink
Merge pull request #219 from platformsh/expose-mockapi-delete-tests
Browse files Browse the repository at this point in the history
Expose mockapi and move tests out to legacy-cli repository
  • Loading branch information
akalipetis authored Nov 28, 2024
2 parents a155342 + d5b27ab commit d7b863b
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 1,217 deletions.
9 changes: 0 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ build:
- dist/
expire_in: 1 day

integration-test-linux:
stage: integration-test
image: cimg/go:1.22
extends: .go-cache
dependencies:
- build
script: |
TEST_CLI_PATH=$PWD/dist/platform_linux_amd64_v1/platform go test -v ./tests/...
release:
stage: release
rules:
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ release: goreleaser clean-phar internal/legacy/archives/platform.phar php ## Rel
.PHONY: test
test: ## Run unit tests
go clean -testcache
go test -v -race -short -cover ./...

.PHONY: integration-test
integration-test: single
go test -v ./tests/...
go test -v -race -mod=readonly -cover ./...

golangci-lint:
command -v golangci-lint >/dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewHandler(t *testing.T) *Handler {

h.Mux.Post("/organizations/{id}/subscriptions", h.handleCreateSubscription)
h.Mux.Get("/subscriptions/{id}", h.handleGetSubscription)
h.Mux.Get("/organizations/{id}/subscriptions/can-create", h.handleCanCreateSubscriptions)
h.Mux.Get("/organizations/{id}/setup/options", func(w http.ResponseWriter, _ *http.Request) {
type options struct {
Plans []string `json:"plans"`
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions internal/mockapi/model.go → pkg/mockapi/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ type Subscription struct {
ProjectUI string `json:"project_ui"`
}

type CanCreateRequiredAction struct {
Action string `json:"action"`
Type string `json:"type"`
}

type CanCreateResponse struct {
CanCreate bool `json:"can_create"`
Message string `json:"message"`

RequiredAction *CanCreateRequiredAction `json:"required_action"`
}

type ProjectRepository struct {
URL string `json:"url"`
}
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions internal/mockapi/store.go → pkg/mockapi/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type store struct {
subscriptions map[string]*Subscription
userGrants []*UserGrant

canCreate map[string]*CanCreateResponse

projectBackups map[string]map[string]*Backup
}

Expand Down Expand Up @@ -43,6 +45,15 @@ func (s *store) SetOrgs(orgs []*Org) {
}
}

func (s *store) SetCanCreate(orgID string, r *CanCreateResponse) {
s.Lock()
defer s.Unlock()
if s.canCreate == nil {
s.canCreate = make(map[string]*CanCreateResponse)
}
s.canCreate[orgID] = r
}

func (s *store) SetUserGrants(grants []*UserGrant) {
s.Lock()
defer s.Unlock()
Expand Down
11 changes: 11 additions & 0 deletions internal/mockapi/subscriptions.go → pkg/mockapi/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ func (h *Handler) handleGetSubscription(w http.ResponseWriter, req *http.Request
}
_ = json.NewEncoder(w).Encode(sub)
}

func (h *Handler) handleCanCreateSubscriptions(w http.ResponseWriter, req *http.Request) {
h.store.RLock()
defer h.store.RUnlock()
id := chi.URLParam(req, "id")
cc := h.store.canCreate[id]
if cc == nil {
cc = &CanCreateResponse{CanCreate: true}
}
_ = json.NewEncoder(w).Encode(cc)
}
File renamed without changes.
96 changes: 0 additions & 96 deletions tests/app_config_test.go

This file was deleted.

76 changes: 0 additions & 76 deletions tests/app_list_test.go

This file was deleted.

52 changes: 0 additions & 52 deletions tests/auth_info_test.go

This file was deleted.

Loading

0 comments on commit d7b863b

Please sign in to comment.