diff --git a/bigquery/integration_test.go b/bigquery/integration_test.go index f83f95ed6375..8a3ed79c5f6a 100644 --- a/bigquery/integration_test.go +++ b/bigquery/integration_test.go @@ -326,17 +326,30 @@ func TestIntegration_UploadAndReadStructs(t *testing.T) { // Test iteration with structs. it := table.Read(ctx) - for i, want := range scores { - var got score - if err := it.Next(&got); err != nil { - t.Fatal(err) + var got []score + for { + var g score + err := it.Next(&g) + if err == iterator.Done { + break } - if got != want { - t.Errorf("%d: got %+v, want %+v", i, got, want) + if err != nil { + t.Fatal(err) } + got = append(got, g) + } + sort.Sort(byName(got)) + if !reflect.DeepEqual(got, scores) { + t.Errorf("got %+v, want %+v", got, scores) } } +type byName []score + +func (b byName) Len() int { return len(b) } +func (b byName) Swap(i, j int) { b[i], b[j] = b[j], b[i] } +func (b byName) Less(i, j int) bool { return b[i].Name < b[j].Name } + func TestIntegration_Update(t *testing.T) { if client == nil { t.Skip("Integration tests skipped")