(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestWriteSchemaWithClusteringKeys(t *testing.T) { |
| 326 | var buf bytes.Buffer |
| 327 | |
| 328 | di := &sdata.DBInfo{ |
| 329 | Type: "snowflake", |
| 330 | Version: 1, |
| 331 | Schema: "main", |
| 332 | Tables: []sdata.DBTable{ |
| 333 | { |
| 334 | Name: "events", |
| 335 | Schema: "main", |
| 336 | Columns: []sdata.DBColumn{ |
| 337 | {Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true, Schema: "main", Table: "events"}, |
| 338 | {Name: "created_at", Type: "timestamp", NotNull: true, Schema: "main", Table: "events"}, |
| 339 | {Name: "region", Type: "varchar", NotNull: true, Schema: "main", Table: "events"}, |
| 340 | }, |
| 341 | ClusteringKeys: []string{"created_at", "region"}, |
| 342 | }, |
| 343 | }, |
| 344 | } |
| 345 | |
| 346 | if err := writeSchema(di, &buf); err != nil { |
| 347 | t.Fatal(err) |
| 348 | } |
| 349 | |
| 350 | output := buf.String() |
| 351 | |
| 352 | if !strings.Contains(output, `@cluster(columns: ["created_at", "region"])`) { |
| 353 | t.Errorf("expected @cluster directive in output, got:\n%s", output) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | func TestSchemaRoundTrip_ClusteringKeys(t *testing.T) { |
| 358 | schema := []byte(`# dbinfo:snowflake,1,main |
nothing calls this directly
no test coverage detected