feat: unify account environments and work collection
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
hub "git.ipao.vip/rogee/creator-hub/internal/environment"
|
||||
)
|
||||
|
||||
func TestAccountEnvironmentViewPreservesDatabaseOrderingID(t *testing.T) {
|
||||
view := accountEnvironmentView(hub.EnvironmentContext{Env: hub.Env{ID: 42, Alias: "env-order"}})
|
||||
if view["id"] != int64(42) {
|
||||
t.Fatalf("account environment is missing its shared ordering ID: %#v", view)
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func PhaseAError(c fiber.Ctx, err error) error {
|
||||
func accountEnvironmentView(environment hub.EnvironmentContext) map[string]any {
|
||||
scheduleStatus, scheduleBlockReason := environmentScheduleReadiness(environment)
|
||||
return map[string]any{
|
||||
"alias": environment.Alias, "name": environment.Name, "gateway": environment.Gateway,
|
||||
"id": environment.ID, "alias": environment.Alias, "name": environment.Name, "gateway": environment.Gateway,
|
||||
"binding_version": environment.BindingVersion, "runtime_id": environment.RuntimeID,
|
||||
"runtime_cleanup_pending": environment.RuntimeCleanupPending,
|
||||
"network_exit_id": environment.Exit.ID, "network_exit_health": environment.Exit.HealthStatus,
|
||||
|
||||
@@ -95,8 +95,8 @@ func TestPendingEnvironmentLoginRoutesKeepBrowserIdentity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
pending, err := hs.ListPendingEnvironments(ctx)
|
||||
if err != nil || len(pending) != 1 {
|
||||
t.Fatalf("pending browser created account: %v %v", pending, err)
|
||||
if err != nil || len(pending) != 1 || pending[0].ID != env.ID || env.ID < 1 {
|
||||
t.Fatalf("pending browser created account or lost its ordering ID: %v %v", pending, err)
|
||||
}
|
||||
logged = true
|
||||
response := do(app, http.MethodPost, route+"/verify", `{}`)
|
||||
@@ -108,7 +108,7 @@ func TestPendingEnvironmentLoginRoutesKeepBrowserIdentity(t *testing.T) {
|
||||
t.Fatalf("login response: %#v %v", result, err)
|
||||
}
|
||||
bound, err := hs.GetEnvironmentContext(ctx, alias)
|
||||
if err != nil || bound.AccountID != result.AccountID || bound.RuntimeID != "login-runtime" || bound.ProfileID != alias || bound.Fingerprint.Seed != env.Fingerprint.Seed {
|
||||
if err != nil || bound.AccountID != result.AccountID || bound.RuntimeID != "login-runtime" || bound.ProfileID != alias || bound.Fingerprint.Seed != env.Fingerprint.Seed || bound.ID != env.ID {
|
||||
t.Fatalf("binding changed browser: %#v %v", bound, err)
|
||||
}
|
||||
response = do(app, http.MethodPost, route+"/verify", `{}`)
|
||||
|
||||
@@ -283,6 +283,7 @@ func TestControlPlaneRegisteredRouteMatrix(t *testing.T) {
|
||||
want int
|
||||
}{
|
||||
{http.MethodPost, "/api/not-registered", http.StatusNotFound},
|
||||
{http.MethodPost, "/api/phase-a/accounts", http.StatusNotFound},
|
||||
{http.MethodDelete, "/api/not-registered", http.StatusNotFound},
|
||||
} {
|
||||
t.Run("unregistered "+route.method, func(t *testing.T) {
|
||||
@@ -359,7 +360,6 @@ func controlPlaneRouteMatrix() []controlPlaneRouteCase {
|
||||
{http.MethodPut, "/api/gateways/:name", "/api/gateways/missing", `{"name":"gw-missing","endpoint":"http://gw-missing:8081","token":""}`, http.StatusNotFound},
|
||||
{http.MethodDelete, "/api/gateways/:name", "/api/gateways/missing", "", http.StatusNotFound},
|
||||
|
||||
{http.MethodPost, "/api/phase-a/accounts", "/api/phase-a/accounts", "", http.StatusBadRequest},
|
||||
{http.MethodGet, "/api/phase-a/accounts", "/api/phase-a/accounts", "", http.StatusOK},
|
||||
{http.MethodGet, "/api/phase-a/accounts/:id", "/api/phase-a/accounts/missing", "", http.StatusNotFound},
|
||||
{http.MethodPost, "/api/phase-a/accounts/:id/pause", "/api/phase-a/accounts/missing/pause", "", http.StatusNotFound},
|
||||
|
||||
Reference in New Issue
Block a user