@@ -233,29 +233,47 @@ func TestIntegration_DatasetUpdateDefaultCollation(t *testing.T) {
233
233
if client == nil {
234
234
t .Skip ("Integration tests skipped" )
235
235
}
236
+ caseInsensitiveCollation := "und:ci"
237
+ caseSensitiveCollation := ""
238
+
236
239
ctx := context .Background ()
237
- _ , err := dataset .Metadata (ctx )
240
+ ds := client .Dataset (datasetIDs .New ())
241
+ err := ds .Create (ctx , & DatasetMetadata {
242
+ DefaultCollation : caseSensitiveCollation ,
243
+ })
238
244
if err != nil {
239
245
t .Fatal (err )
240
246
}
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 {
244
257
DefaultCollation : caseInsensitiveCollation ,
245
258
}, "" )
246
259
if err != nil {
247
260
t .Fatal (err )
248
261
}
249
262
if md .DefaultCollation != caseInsensitiveCollation {
250
- t .Fatalf ("got %q, want und:ci " , md .DefaultCollation )
263
+ t .Fatalf ("got %q, want %q " , md .DefaultCollation , caseInsensitiveCollation )
251
264
}
265
+
252
266
// Omitting DefaultCollation doesn't change it.
253
- md , err = dataset .Update (ctx , DatasetMetadataToUpdate {Name : "xyz" }, "" )
267
+ md , err = ds .Update (ctx , DatasetMetadataToUpdate {Name : "xyz" }, "" )
254
268
if err != nil {
255
269
t .Fatal (err )
256
270
}
257
271
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 )
259
277
}
260
278
}
261
279
0 commit comments