Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align MSP signup route tests

rcourtmand92820cf531c
diff --git a/internal/cloudcp/account/tenant_handlers_test.go b/internal/cloudcp/account/tenant_handlers_test.go
index 672e43a2c0..96bdc325fb 100644
--- a/internal/cloudcp/account/tenant_handlers_test.go
+++ b/internal/cloudcp/account/tenant_handlers_test.go
@@ -19,6 +19,7 @@ import (
cpstripe "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/stripe"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
+ pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"
)
func newTestTenantMux(t *testing.T, reg *registry.TenantRegistry, tenantsDir string) (*http.ServeMux, *cpstripe.Provisioner) {
@@ -372,23 +373,26 @@ func TestCreateWorkspace_MSPStarterLimitEnforced(t *testing.T) {
if err := reg.CreateAccount(&registry.Account{ID: accountID, Kind: registry.AccountKindMSP, DisplayName: "MSP Starter"}); err != nil {
t.Fatal(err)
}
- createTestStripeAccount(t, reg, accountID, "msp_starter") // limit = 10
+ createTestStripeAccount(t, reg, accountID, "msp_starter")
+ workspaceLimit, known := pkglicensing.WorkspaceLimitForPlan("msp_starter")
+ if !known {
+ t.Fatal("msp_starter workspace limit is not registered")
+ }
- // Create 10 workspaces (the limit for msp_starter).
- for i := 0; i < 10; i++ {
+ for i := 0; i < workspaceLimit; i++ {
if _, err := provisioner.ProvisionWorkspace(context.Background(), accountID, fmt.Sprintf("Client %d", i+1)); err != nil {
t.Fatalf("provision workspace %d: %v", i+1, err)
}
}
- if _, err := provisioner.ProvisionWorkspace(context.Background(), accountID, "Client 11 direct"); err == nil {
+ if _, err := provisioner.ProvisionWorkspace(context.Background(), accountID, fmt.Sprintf("Client %d direct", workspaceLimit+1)); err == nil {
t.Fatal("expected registry-backed workspace limit to block direct provisioning")
} else if _, ok := registry.WorkspaceLimitExceeded(err); !ok {
t.Fatalf("direct provision error = %v, want workspace limit", err)
}
// The handler should also return the product-level limit response.
- body := `{"display_name":"Client 11"}`
+ body := fmt.Sprintf(`{"display_name":"Client %d"}`, workspaceLimit+1)
req := httptest.NewRequest(http.MethodPost, "/api/accounts/"+accountID+"/tenants", bytes.NewBufferString(body))
rec := doRequest(t, mux, req)
diff --git a/internal/cloudcp/routes_test.go b/internal/cloudcp/routes_test.go
index 509ab10cca..3c1bddd078 100644
--- a/internal/cloudcp/routes_test.go
+++ b/internal/cloudcp/routes_test.go
@@ -266,7 +266,7 @@ func TestRegisterRoutes_PublicMSPSignupRoutes(t *testing.T) {
if mspPageRec.Code != http.StatusOK {
t.Fatalf("GET /cloud/msp/signup status=%d, want %d", mspPageRec.Code, http.StatusOK)
}
- if !strings.Contains(mspPageRec.Body.String(), "Pulse Cloud for MSPs") {
+ if !strings.Contains(mspPageRec.Body.String(), "Start Pulse MSP Starter") {
t.Fatalf("expected public MSP signup page body")
}