(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestComputeDiff_BigQueryDDLWithDataset(t *testing.T) { |
| 119 | current := &sdata.DBInfo{Type: "bigquery"} |
| 120 | expected := sdata.NewDBInfo("bigquery", 0, "analytics", "project", []sdata.DBColumn{ |
| 121 | {Schema: "analytics", Table: "users", Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true}, |
| 122 | {Schema: "analytics", Table: "orders", Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true}, |
| 123 | {Schema: "analytics", Table: "orders", Name: "user_id", Type: "bigint", FKeySchema: "analytics", FKeyTable: "users", FKeyCol: "id"}, |
| 124 | }, nil, nil) |
| 125 | |
| 126 | ops := computeDiff(current, expected, DiffOptions{}) |
| 127 | var usersSQL, ordersSQL string |
| 128 | for _, op := range ops { |
| 129 | if op.Type == "create_table" && op.Table == "users" { |
| 130 | usersSQL = op.SQL |
| 131 | } |
| 132 | if op.Type == "create_table" && op.Table == "orders" { |
| 133 | ordersSQL = op.SQL |
| 134 | } |
| 135 | } |
| 136 | if !strings.Contains(usersSQL, "CREATE TABLE `analytics.users`") { |
| 137 | t.Fatalf("bigquery users DDL missing dataset-qualified table:\n%s", usersSQL) |
| 138 | } |
| 139 | if !strings.Contains(ordersSQL, "REFERENCES `analytics.users`(`id`) NOT ENFORCED") { |
| 140 | t.Fatalf("bigquery orders DDL missing dataset-qualified FK:\n%s", ordersSQL) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestComputeDiff_RedshiftDDL(t *testing.T) { |
| 145 | current := &sdata.DBInfo{Type: "redshift"} |
nothing calls this directly
no test coverage detected