(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestComputeDiff_BigQueryDDL(t *testing.T) { |
| 88 | current := &sdata.DBInfo{Type: "bigquery"} |
| 89 | expected := sdata.NewDBInfo("bigquery", 0, "", "project", []sdata.DBColumn{ |
| 90 | {Schema: "", Table: "users", Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true}, |
| 91 | {Schema: "", Table: "users", Name: "email", Type: "text", NotNull: true}, |
| 92 | {Schema: "", Table: "orders", Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true}, |
| 93 | {Schema: "", Table: "orders", Name: "user_id", Type: "bigint", FKeyTable: "users", FKeyCol: "id"}, |
| 94 | {Schema: "", Table: "orders", Name: "tags", Type: "text", Array: true}, |
| 95 | }, nil, nil) |
| 96 | |
| 97 | ops := computeDiff(current, expected, DiffOptions{}) |
| 98 | var usersSQL, ordersSQL string |
| 99 | for _, op := range ops { |
| 100 | if op.Type == "create_table" && op.Table == "users" { |
| 101 | usersSQL = op.SQL |
| 102 | } |
| 103 | if op.Type == "create_table" && op.Table == "orders" { |
| 104 | ordersSQL = op.SQL |
| 105 | } |
| 106 | } |
| 107 | if !strings.Contains(usersSQL, "`id` INT64 NOT NULL PRIMARY KEY NOT ENFORCED") { |
| 108 | t.Fatalf("bigquery users DDL missing non-enforced primary key:\n%s", usersSQL) |
| 109 | } |
| 110 | if !strings.Contains(ordersSQL, "REFERENCES `users`(`id`) NOT ENFORCED") { |
| 111 | t.Fatalf("bigquery orders DDL missing non-enforced foreign key:\n%s", ordersSQL) |
| 112 | } |
| 113 | if !strings.Contains(ordersSQL, "`tags` ARRAY<STRING>") { |
| 114 | t.Fatalf("bigquery orders DDL missing array type:\n%s", ordersSQL) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func TestComputeDiff_BigQueryDDLWithDataset(t *testing.T) { |
| 119 | current := &sdata.DBInfo{Type: "bigquery"} |
nothing calls this directly
no test coverage detected