MCPcopy Index your code
hub / github.com/dosco/graphjin / TestComputeDiff_WithDefault

Function TestComputeDiff_WithDefault

core/schema_diff_test.go:1734–1772  ·  view source on GitHub ↗

============================================================================ ComputeDiff Integration Tests with New Features ============================================================================

(t *testing.T)

Source from the content-addressed store, hash-verified

1732// ============================================================================
1733
1734func TestComputeDiff_WithDefault(t *testing.T) {
1735 current := &sdata.DBInfo{
1736 Type: "postgres",
1737 Tables: []sdata.DBTable{},
1738 }
1739
1740 expected := &sdata.DBInfo{
1741 Type: "postgres",
1742 Tables: []sdata.DBTable{
1743 {
1744 Name: "orders",
1745 Columns: []sdata.DBColumn{
1746 {Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true},
1747 {Name: "status", Type: "text", NotNull: true, Default: "'pending'"},
1748 },
1749 },
1750 },
1751 }
1752
1753 ops := computeDiff(current, expected, DiffOptions{Destructive: false})
1754
1755 if len(ops) == 0 {
1756 t.Fatal("expected at least one operation")
1757 }
1758
1759 found := false
1760 for _, op := range ops {
1761 if op.Type == "create_table" && op.Table == "orders" {
1762 found = true
1763 if !strings.Contains(op.SQL, "DEFAULT 'pending'") {
1764 t.Errorf("expected DEFAULT 'pending' in SQL, got: %s", op.SQL)
1765 }
1766 }
1767 }
1768
1769 if !found {
1770 t.Error("expected create_table operation for orders table")
1771 }
1772}
1773
1774func TestComputeDiff_WithIndex(t *testing.T) {
1775 current := &sdata.DBInfo{

Callers

nothing calls this directly

Calls 2

computeDiffFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected