Enforce 10j's verified gaps (schema-hardening change): - Migration 00010: partial unique indexes for one default pool and one primary assignment per workspace, plus CHECKs pinning pool/provider/subscription vocabularies and provider lifecycle timestamps. - Workspace creation shares a transactional provisioning function; extension validates its target pool; last-tier deletion of a defaulted ladder is guarded; signup completes plan-less on a broken ladder. - Boot asserts integration slug parity and validates declared config enums; Stripe invoice amounts are range-checked; domain cancellation runs a final evidence probe; rule authoring is additive-only.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package integration
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAssertSlugMatch(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
codeSlug string
|
|
manifest Manifest
|
|
wantErr bool
|
|
wantMsg []string // substrings the error must contain, when wantErr
|
|
}{
|
|
{
|
|
name: "matching slugs pass",
|
|
codeSlug: "discourse",
|
|
manifest: Manifest{Slug: "discourse", DisplayName: "Discourse"},
|
|
},
|
|
{
|
|
name: "matching slugs pass with no display name",
|
|
codeSlug: "fedwiki",
|
|
manifest: Manifest{Slug: "fedwiki"},
|
|
},
|
|
{
|
|
name: "mismatched slugs fail naming both strings",
|
|
codeSlug: "discourse",
|
|
manifest: Manifest{Slug: "forum", DisplayName: "Discourse"},
|
|
wantErr: true,
|
|
wantMsg: []string{"Discourse", "discourse", "forum"},
|
|
},
|
|
{
|
|
name: "mismatched slugs fail and fall back to codeSlug when DisplayName is empty",
|
|
codeSlug: "discourse",
|
|
manifest: Manifest{Slug: "forum"},
|
|
wantErr: true,
|
|
wantMsg: []string{"discourse", "forum"},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := AssertSlugMatch(tt.codeSlug, tt.manifest)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("AssertSlugMatch() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
if !tt.wantErr {
|
|
return
|
|
}
|
|
got := err.Error()
|
|
for _, want := range tt.wantMsg {
|
|
if !strings.Contains(got, want) {
|
|
t.Errorf("error %q missing %q", got, want)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|