============================================================================ ComputeDiff Integration Tests with New Features ============================================================================
(t *testing.T)
| 1732 | // ============================================================================ |
| 1733 | |
| 1734 | func 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 | |
| 1774 | func TestComputeDiff_WithIndex(t *testing.T) { |
| 1775 | current := &sdata.DBInfo{ |
nothing calls this directly
no test coverage detected