Skip to content

Commit b371558

Browse files
authored
fix(bigquery): create/update an isolated dataset for collation feature (#7256)
Resolves flaky tests from https://togithub.com/googleapis/google-cloud-go/issues/7254
1 parent ecf14d4 commit b371558

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

bigquery/dataset_integration_test.go

+25-7
Original file line numberDiff line numberDiff line change
@@ -233,29 +233,47 @@ func TestIntegration_DatasetUpdateDefaultCollation(t *testing.T) {
233233
if client == nil {
234234
t.Skip("Integration tests skipped")
235235
}
236+
caseInsensitiveCollation := "und:ci"
237+
caseSensitiveCollation := ""
238+
236239
ctx := context.Background()
237-
_, err := dataset.Metadata(ctx)
240+
ds := client.Dataset(datasetIDs.New())
241+
err := ds.Create(ctx, &DatasetMetadata{
242+
DefaultCollation: caseSensitiveCollation,
243+
})
238244
if err != nil {
239245
t.Fatal(err)
240246
}
241-
caseInsensitiveCollation := "und:ci"
242-
// Set the default collation
243-
md, err := dataset.Update(ctx, DatasetMetadataToUpdate{
247+
md, err := ds.Metadata(ctx)
248+
if err != nil {
249+
t.Fatal(err)
250+
}
251+
if md.DefaultCollation != caseSensitiveCollation {
252+
t.Fatalf("got %q, want %q", md.DefaultCollation, caseSensitiveCollation)
253+
}
254+
255+
// Update the default collation
256+
md, err = ds.Update(ctx, DatasetMetadataToUpdate{
244257
DefaultCollation: caseInsensitiveCollation,
245258
}, "")
246259
if err != nil {
247260
t.Fatal(err)
248261
}
249262
if md.DefaultCollation != caseInsensitiveCollation {
250-
t.Fatalf("got %q, want und:ci", md.DefaultCollation)
263+
t.Fatalf("got %q, want %q", md.DefaultCollation, caseInsensitiveCollation)
251264
}
265+
252266
// Omitting DefaultCollation doesn't change it.
253-
md, err = dataset.Update(ctx, DatasetMetadataToUpdate{Name: "xyz"}, "")
267+
md, err = ds.Update(ctx, DatasetMetadataToUpdate{Name: "xyz"}, "")
254268
if err != nil {
255269
t.Fatal(err)
256270
}
257271
if md.DefaultCollation != caseInsensitiveCollation {
258-
t.Fatalf("got %q, want und:ci", md.DefaultCollation)
272+
t.Fatalf("got %q, want %q", md.DefaultCollation, caseInsensitiveCollation)
273+
}
274+
275+
if err := ds.Delete(ctx); err != nil {
276+
t.Fatalf("deleting dataset %v: %v", ds, err)
259277
}
260278
}
261279

0 commit comments

Comments
 (0)