Skip to content

Commit

Permalink
test(bigquery): address minor test issues (#6202)
Browse files Browse the repository at this point in the history
in the first, the integration tests running too long came into conflict
with a expiration time that was too short.  lengthened the test
accordingly.

In the second, cleanup some usages of xerrors that can be moved to
errors as we're now no longer supporting older go versions.
  • Loading branch information
shollyman authored Jun 16, 2022
1 parent 507a2be commit 001d08b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bigquery/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package bigquery
import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"log"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
gax "github.com/googleapis/gax-go/v2"
"golang.org/x/xerrors"
"google.golang.org/api/googleapi"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
Expand Down Expand Up @@ -216,7 +216,7 @@ func initTestState(client *Client, t time.Time) func() {
tableIDs = uid.NewSpace("table", opts)
modelIDs = uid.NewSpace("model", opts)
routineIDs = uid.NewSpace("routine", opts)
testTableExpiration = t.Add(10 * time.Minute).Round(time.Second)
testTableExpiration = t.Add(2 * time.Hour).Round(time.Second)
// For replayability, seed the random source with t.
Seed(t.UnixNano())

Expand Down Expand Up @@ -866,7 +866,7 @@ func TestIntegration_InsertErrors(t *testing.T) {
t.Errorf("Wanted row size error, got successful insert.")
}
var e1 *googleapi.Error
ok := xerrors.As(err, &e1)
ok := errors.As(err, &e1)
if !ok {
t.Errorf("Wanted googleapi.Error, got: %v", err)
}
Expand All @@ -886,7 +886,7 @@ func TestIntegration_InsertErrors(t *testing.T) {
t.Errorf("Wanted error, got successful insert.")
}
var e2 *googleapi.Error
ok = xerrors.As(err, &e2)
ok = errors.As(err, &e2)
if !ok {
t.Errorf("wanted googleapi.Error, got: %v", err)
}
Expand Down Expand Up @@ -1437,15 +1437,15 @@ func runQueryJob(ctx context.Context, q *Query) (*JobStatistics, *QueryStatistic
job, err := q.Run(ctx)
if err != nil {
var e *googleapi.Error
if ok := xerrors.As(err, &e); ok && e.Code < 500 {
if ok := errors.As(err, &e); ok && e.Code < 500 {
return true, err // fail on 4xx
}
return false, err
}
_, err = job.Wait(ctx)
if err != nil {
var e *googleapi.Error
if ok := xerrors.As(err, &e); ok && e.Code < 500 {
if ok := errors.As(err, &e); ok && e.Code < 500 {
return true, err // fail on 4xx
}
return false, fmt.Errorf("%q: %v", job.ID(), err)
Expand Down Expand Up @@ -2792,7 +2792,7 @@ func (b byCol0) Less(i, j int) bool {

func hasStatusCode(err error, code int) bool {
var e *googleapi.Error
if ok := xerrors.As(err, &e); ok && e.Code == code {
if ok := errors.As(err, &e); ok && e.Code == code {
return true
}
return false
Expand Down

0 comments on commit 001d08b

Please sign in to comment.