Skip to content

Commit

Permalink
fix(bigquery): create/update an isolated dataset for collation feature (
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx authored Jan 17, 2023
1 parent ecf14d4 commit b371558
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions bigquery/dataset_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,47 @@ func TestIntegration_DatasetUpdateDefaultCollation(t *testing.T) {
if client == nil {
t.Skip("Integration tests skipped")
}
caseInsensitiveCollation := "und:ci"
caseSensitiveCollation := ""

ctx := context.Background()
_, err := dataset.Metadata(ctx)
ds := client.Dataset(datasetIDs.New())
err := ds.Create(ctx, &DatasetMetadata{
DefaultCollation: caseSensitiveCollation,
})
if err != nil {
t.Fatal(err)
}
caseInsensitiveCollation := "und:ci"
// Set the default collation
md, err := dataset.Update(ctx, DatasetMetadataToUpdate{
md, err := ds.Metadata(ctx)
if err != nil {
t.Fatal(err)
}
if md.DefaultCollation != caseSensitiveCollation {
t.Fatalf("got %q, want %q", md.DefaultCollation, caseSensitiveCollation)
}

// Update the default collation
md, err = ds.Update(ctx, DatasetMetadataToUpdate{
DefaultCollation: caseInsensitiveCollation,
}, "")
if err != nil {
t.Fatal(err)
}
if md.DefaultCollation != caseInsensitiveCollation {
t.Fatalf("got %q, want und:ci", md.DefaultCollation)
t.Fatalf("got %q, want %q", md.DefaultCollation, caseInsensitiveCollation)
}

// Omitting DefaultCollation doesn't change it.
md, err = dataset.Update(ctx, DatasetMetadataToUpdate{Name: "xyz"}, "")
md, err = ds.Update(ctx, DatasetMetadataToUpdate{Name: "xyz"}, "")
if err != nil {
t.Fatal(err)
}
if md.DefaultCollation != caseInsensitiveCollation {
t.Fatalf("got %q, want und:ci", md.DefaultCollation)
t.Fatalf("got %q, want %q", md.DefaultCollation, caseInsensitiveCollation)
}

if err := ds.Delete(ctx); err != nil {
t.Fatalf("deleting dataset %v: %v", ds, err)
}
}

Expand Down

0 comments on commit b371558

Please sign in to comment.