Skip to content

Commit

Permalink
bigquery: fix integration test
Browse files Browse the repository at this point in the history
Since Table.Read can return rows in any order, sort results in the
UploadAndReadStructs test.

Change-Id: I1d3fc80ed8a6887a22f88ba0028352c7e7c02f73
Reviewed-on: https://code-review.googlesource.com/9722
Reviewed-by: Sai Cheemalapati <saicheems@google.com>
  • Loading branch information
jba committed Dec 6, 2016
1 parent 7f16067 commit e882659
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions bigquery/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e882659

Please sign in to comment.