More Roundtrip tests
Some checks are pending
CI / Test (1.23) (push) Waiting to run
CI / Test (1.24) (push) Waiting to run
CI / Test (1.25) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Build (push) Waiting to run

This commit is contained in:
2025-12-17 22:52:24 +02:00
parent 5e1448dcdb
commit a427aa5537
23 changed files with 22897 additions and 1319 deletions

View File

@@ -445,3 +445,51 @@ func TestColumnProperties(t *testing.T) {
t.Log("Note: No columns with default values found (this may be valid for the test data)")
}
}
func TestRelationships(t *testing.T) {
opts := &readers.ReaderOptions{
FilePath: filepath.Join("..", "..", "..", "examples", "dctx", "example.dctx"),
}
reader := NewReader(opts)
db, err := reader.ReadDatabase()
if err != nil {
t.Fatalf("ReadDatabase() error = %v", err)
}
// Count total relationships across all tables
relationshipCount := 0
for _, schema := range db.Schemas {
for _, table := range schema.Tables {
relationshipCount += len(table.Relationships)
}
}
// The example.dctx file should have a significant number of relationships
// With the fix for nested field GUID mapping, we expect around 100+ relationships
if relationshipCount < 50 {
t.Errorf("Expected at least 50 relationships, got %d. This may indicate relationships are not being parsed correctly", relationshipCount)
}
t.Logf("Successfully parsed %d relationships", relationshipCount)
// Verify relationship properties
for _, schema := range db.Schemas {
for _, table := range schema.Tables {
for _, rel := range table.Relationships {
if rel.Name == "" {
t.Errorf("Relationship in table '%s' should have a name", table.Name)
}
if rel.FromTable == "" {
t.Errorf("Relationship '%s' should have a from table", rel.Name)
}
if rel.ToTable == "" {
t.Errorf("Relationship '%s' should have a to table", rel.Name)
}
if rel.ForeignKey == "" {
t.Errorf("Relationship '%s' should reference a foreign key", rel.Name)
}
}
}
}
}