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

Function TestComputeDiff_BigQueryDDLWithDataset

core/schema_diff_test.go:118–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func 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
144func TestComputeDiff_RedshiftDDL(t *testing.T) {
145 current := &sdata.DBInfo{Type: "redshift"}

Callers

nothing calls this directly

Calls 1

computeDiffFunction · 0.85

Tested by

no test coverage detected