mirror of
https://github.com/rclone/rclone.git
synced 2026-01-02 08:33:50 +00:00
vendor: update all dependencies
* Update all dependencies * Remove all `[[constraint]]` from Gopkg.toml * Add in the minimum number of `[[override]]` to build * Remove go get of github.com/inconshreveable/mousetrap as it is vendored * Update docs with new policy on constraints
This commit is contained in:
126
vendor/cloud.google.com/go/bigquery/integration_test.go
generated
vendored
126
vendor/cloud.google.com/go/bigquery/integration_test.go
generated
vendored
@@ -59,6 +59,9 @@ var (
|
||||
tableIDs = testutil.NewUIDSpaceSep("table", '_')
|
||||
)
|
||||
|
||||
// Note: integration tests cannot be run in parallel, because TestIntegration_Location
|
||||
// modifies the client.
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
cleanup := initIntegrationTest()
|
||||
r := m.Run()
|
||||
@@ -943,23 +946,23 @@ func TestIntegration_TableUpdate(t *testing.T) {
|
||||
// Error cases when updating schema.
|
||||
for _, test := range []struct {
|
||||
desc string
|
||||
fields []*FieldSchema
|
||||
fields Schema
|
||||
}{
|
||||
{"change from optional to required", []*FieldSchema{
|
||||
{"change from optional to required", Schema{
|
||||
{Name: "name", Type: StringFieldType, Required: true},
|
||||
schema3[1],
|
||||
schema3[2],
|
||||
schema3[3],
|
||||
}},
|
||||
{"add a required field", []*FieldSchema{
|
||||
{"add a required field", Schema{
|
||||
schema3[0], schema3[1], schema3[2], schema3[3],
|
||||
{Name: "req", Type: StringFieldType, Required: true},
|
||||
}},
|
||||
{"remove a field", []*FieldSchema{schema3[0], schema3[1], schema3[2]}},
|
||||
{"remove a nested field", []*FieldSchema{
|
||||
{"remove a field", Schema{schema3[0], schema3[1], schema3[2]}},
|
||||
{"remove a nested field", Schema{
|
||||
schema3[0], schema3[1], schema3[2],
|
||||
{Name: "rec2", Type: RecordFieldType, Schema: Schema{nested[0]}}}},
|
||||
{"remove all nested fields", []*FieldSchema{
|
||||
{"remove all nested fields", Schema{
|
||||
schema3[0], schema3[1], schema3[2],
|
||||
{Name: "rec2", Type: RecordFieldType, Schema: Schema{}}}},
|
||||
} {
|
||||
@@ -1603,6 +1606,117 @@ func TestIntegration_ListJobs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const tokyo = "asia-northeast1"
|
||||
|
||||
func TestIntegration_Location(t *testing.T) {
|
||||
if client == nil {
|
||||
t.Skip("Integration tests skipped")
|
||||
}
|
||||
client.Location = ""
|
||||
testLocation(t, tokyo)
|
||||
client.Location = tokyo
|
||||
defer func() {
|
||||
client.Location = ""
|
||||
}()
|
||||
testLocation(t, "")
|
||||
}
|
||||
|
||||
func testLocation(t *testing.T, loc string) {
|
||||
ctx := context.Background()
|
||||
tokyoDataset := client.Dataset("tokyo")
|
||||
err := tokyoDataset.Create(ctx, &DatasetMetadata{Location: loc})
|
||||
if err != nil && !hasStatusCode(err, 409) { // 409 = already exists
|
||||
t.Fatal(err)
|
||||
}
|
||||
md, err := tokyoDataset.Metadata(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if md.Location != tokyo {
|
||||
t.Fatalf("dataset location: got %s, want %s", md.Location, tokyo)
|
||||
}
|
||||
table := tokyoDataset.Table(tableIDs.New())
|
||||
err = table.Create(context.Background(), &TableMetadata{
|
||||
Schema: Schema{
|
||||
{Name: "name", Type: StringFieldType},
|
||||
{Name: "nums", Type: IntegerFieldType},
|
||||
},
|
||||
ExpirationTime: testTableExpiration,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer table.Delete(ctx)
|
||||
loader := table.LoaderFrom(NewReaderSource(strings.NewReader("a,0\nb,1\nc,2\n")))
|
||||
loader.Location = loc
|
||||
job, err := loader.Run(ctx)
|
||||
if err != nil {
|
||||
t.Fatal("loader.Run", err)
|
||||
}
|
||||
if job.Location() != tokyo {
|
||||
t.Fatalf("job location: got %s, want %s", job.Location(), tokyo)
|
||||
}
|
||||
_, err = client.JobFromID(ctx, job.ID())
|
||||
if client.Location == "" && err == nil {
|
||||
t.Error("JobFromID with Tokyo job, no client location: want error, got nil")
|
||||
}
|
||||
if client.Location != "" && err != nil {
|
||||
t.Errorf("JobFromID with Tokyo job, with client location: want nil, got %v", err)
|
||||
}
|
||||
_, err = client.JobFromIDLocation(ctx, job.ID(), "US")
|
||||
if err == nil {
|
||||
t.Error("JobFromIDLocation with US: want error, got nil")
|
||||
}
|
||||
job2, err := client.JobFromIDLocation(ctx, job.ID(), loc)
|
||||
if loc == tokyo && err != nil {
|
||||
t.Errorf("loc=tokyo: %v", err)
|
||||
}
|
||||
if loc == "" && err == nil {
|
||||
t.Error("loc empty: got nil, want error")
|
||||
}
|
||||
if job2 != nil && (job2.ID() != job.ID() || job2.Location() != tokyo) {
|
||||
t.Errorf("got id %s loc %s, want id%s loc %s", job2.ID(), job2.Location(), job.ID(), tokyo)
|
||||
}
|
||||
if err := wait(ctx, job); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Cancel should succeed even if the job is done.
|
||||
if err := job.Cancel(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
q := client.Query(fmt.Sprintf("SELECT * FROM %s.%s", table.DatasetID, table.TableID))
|
||||
q.Location = loc
|
||||
iter, err := q.Read(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wantRows := [][]Value{
|
||||
[]Value{"a", int64(0)},
|
||||
[]Value{"b", int64(1)},
|
||||
[]Value{"c", int64(2)},
|
||||
}
|
||||
checkRead(t, "location", iter, wantRows)
|
||||
|
||||
table2 := tokyoDataset.Table(tableIDs.New())
|
||||
copier := table2.CopierFrom(table)
|
||||
copier.Location = loc
|
||||
if _, err := copier.Run(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
bucketName := testutil.ProjID()
|
||||
objectName := fmt.Sprintf("bq-test-%s.csv", table.TableID)
|
||||
uri := fmt.Sprintf("gs://%s/%s", bucketName, objectName)
|
||||
defer storageClient.Bucket(bucketName).Object(objectName).Delete(ctx)
|
||||
gr := NewGCSReference(uri)
|
||||
gr.DestinationFormat = CSV
|
||||
e := table.ExtractorTo(gr)
|
||||
e.Location = loc
|
||||
if _, err := e.Run(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new, temporary table with a unique name and the given schema.
|
||||
func newTable(t *testing.T, s Schema) *Table {
|
||||
table := dataset.Table(tableIDs.New())
|
||||
|
||||
Reference in New Issue
Block a user