Replace the entity slugs on organizations, workspaces, resource pools, and plan ladders with nullable `key` columns and add keys to products, prices, and entitlement sets. Rename `providers.slug` to `provider` and add partial unique indexes for system and org role names. Assign invoice numbers per billing account from a gapless transactional counter; Stripe's number moves to the invoice mapping as an external reference. Seeds, fixtures, and the operator lookup address rows by key, and the returning-login resync no longer blanks a display name when the IdP sends no `name` claim.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package integration
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAssertKeyMatch(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
codeKey string
|
|
manifest Manifest
|
|
wantErr bool
|
|
wantMsg []string // substrings the error must contain, when wantErr
|
|
}{
|
|
{
|
|
name: "matching keys pass",
|
|
codeKey: "discourse",
|
|
manifest: Manifest{Key: "discourse", DisplayName: "Discourse"},
|
|
},
|
|
{
|
|
name: "matching keys pass with no display name",
|
|
codeKey: "fedwiki",
|
|
manifest: Manifest{Key: "fedwiki"},
|
|
},
|
|
{
|
|
name: "mismatched keys fail naming both strings",
|
|
codeKey: "discourse",
|
|
manifest: Manifest{Key: "forum", DisplayName: "Discourse"},
|
|
wantErr: true,
|
|
wantMsg: []string{"Discourse", "discourse", "forum"},
|
|
},
|
|
{
|
|
name: "mismatched keys fail and fall back to codeKey when DisplayName is empty",
|
|
codeKey: "discourse",
|
|
manifest: Manifest{Key: "forum"},
|
|
wantErr: true,
|
|
wantMsg: []string{"discourse", "forum"},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := AssertKeyMatch(tt.codeKey, tt.manifest)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("AssertKeyMatch() 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)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|