feat: add linked mock data seeding CLI
This commit is contained in:
41
backend/api/internal/seed/mock_test.go
Normal file
41
backend/api/internal/seed/mock_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package seed
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMockEntityIdentitiesAreStableAndUnique(t *testing.T) {
|
||||
identityPattern := regexp.MustCompile(
|
||||
`^00000000-0000-7000-8000-[0-9]{12}$`,
|
||||
)
|
||||
seen := make(map[string]struct{}, 46)
|
||||
for sequence := 1; sequence <= 46; sequence++ {
|
||||
record := entity(sequence, "enabled")
|
||||
if !identityPattern.MatchString(record.Identity) {
|
||||
t.Fatalf("entity(%d) identity = %q", sequence, record.Identity)
|
||||
}
|
||||
if _, exists := seen[record.Identity]; exists {
|
||||
t.Fatalf("duplicate identity %q", record.Identity)
|
||||
}
|
||||
seen[record.Identity] = struct{}{}
|
||||
if record.Status != "enabled" || record.Version != 1 {
|
||||
t.Fatalf("entity(%d) has unexpected defaults: %#v", sequence, record)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIdentityOfEmbeddedEntity(t *testing.T) {
|
||||
record := struct {
|
||||
Entity struct {
|
||||
Identity string
|
||||
}
|
||||
}{}
|
||||
record.Entity.Identity = "mock-identity"
|
||||
if got := identityOf(&record); got != record.Entity.Identity {
|
||||
t.Fatalf("identityOf() = %q, want %q", got, record.Entity.Identity)
|
||||
}
|
||||
if got := identityOf(nil); got != "" {
|
||||
t.Fatalf("identityOf(nil) = %q, want empty", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user