Files

39 lines
1.1 KiB
Go
Raw Permalink Normal View History

2026-08-16 11:37:42 +02:00
package catalog
import (
2026-08-16 16:57:36 +02:00
"strings"
2026-08-16 11:37:42 +02:00
"testing"
"github.com/google/uuid"
)
func TestValidateCloneCompanies(t *testing.T) {
t.Parallel()
a := uuid.MustParse("11111111-1111-4111-8111-111111111111")
b := uuid.MustParse("22222222-2222-4222-8222-222222222222")
if err := validateCloneCompanies(uuid.Nil, b); err == nil {
t.Fatal("expected error for nil source")
}
if err := validateCloneCompanies(a, uuid.Nil); err == nil {
t.Fatal("expected error for nil dest")
}
if err := validateCloneCompanies(a, a); err == nil {
t.Fatal("expected error for src==dest")
}
if err := validateCloneCompanies(a, b); err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
2026-08-16 16:57:36 +02:00
func TestCloneFieldSourcesSQLClearsEnhanceHash(t *testing.T) {
t.Parallel()
const want = "enhance_input_hash"
if !strings.Contains(cloneProcessedFieldSourcesSQL, want) {
t.Fatalf("clone field_sources SQL must remove %q; got %q", want, cloneProcessedFieldSourcesSQL)
}
if !strings.Contains(cloneProcessedFieldSourcesSQL, "-") {
t.Fatalf("expected jsonb key removal operator in %q", cloneProcessedFieldSourcesSQL)
}
}