mirror of
https://github.com/restic/restic.git
synced 2026-08-13 00:53:17 +00:00
Update dependencies
Among others, this updates minio-go, so that the new "eu-west-3" zone for AWS is supported.
This commit is contained in:
+74
-18
@@ -114,7 +114,7 @@ func initIntegrationTest() {
|
||||
ctx := context.Background()
|
||||
ts := testutil.TokenSource(ctx, AdminScope, Scope)
|
||||
if ts == nil {
|
||||
log.Print("Integration test skipped: cannot get service account credential from environment variable %v", "GCLOUD_TESTS_GOLANG_KEY")
|
||||
log.Printf("Integration test skipped: cannot get service account credential from environment variable %v", "GCLOUD_TESTS_GOLANG_KEY")
|
||||
return
|
||||
}
|
||||
var err error
|
||||
@@ -164,7 +164,8 @@ func prepare(ctx context.Context, t *testing.T, statements []string) (client *Cl
|
||||
}
|
||||
return client, dbPath, func() {
|
||||
if err := admin.DropDatabase(ctx, &adminpb.DropDatabaseRequest{dbPath}); err != nil {
|
||||
t.Logf("failed to drop testing database: %v, might need a manual removal", dbPath)
|
||||
t.Logf("failed to drop database %s (error %v), might need a manual removal",
|
||||
dbPath, err)
|
||||
}
|
||||
client.Close()
|
||||
}
|
||||
@@ -173,7 +174,7 @@ func prepare(ctx context.Context, t *testing.T, statements []string) (client *Cl
|
||||
// Test SingleUse transaction.
|
||||
func TestSingleUse(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
// Set up testing environment.
|
||||
client, _, tearDown := prepare(ctx, t, singerDBStatements)
|
||||
@@ -278,7 +279,7 @@ func TestSingleUse(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("%d: SingleUse.Query returns error %v, want nil", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected result from SingleUse.Query: %v, want %v", i, got, test.want)
|
||||
}
|
||||
rts, err := su.Timestamp()
|
||||
@@ -294,7 +295,7 @@ func TestSingleUse(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("%d: SingleUse.Read returns error %v, want nil", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected result from SingleUse.Read: %v, want %v", i, got, test.want)
|
||||
}
|
||||
rts, err = su.Timestamp()
|
||||
@@ -325,7 +326,7 @@ func TestSingleUse(t *testing.T) {
|
||||
t.Errorf("%d: SingleUse.ReadRow(%v) doesn't return expected timestamp: %v", i, k, err)
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected results from SingleUse.ReadRow: %v, want %v", i, got, test.want)
|
||||
}
|
||||
// SingleUse.ReadUsingIndex
|
||||
@@ -348,7 +349,7 @@ func TestSingleUse(t *testing.T) {
|
||||
}
|
||||
found := false
|
||||
for _, w := range test.want {
|
||||
if reflect.DeepEqual(g, w) {
|
||||
if testEqual(g, w) {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
@@ -365,6 +366,19 @@ func TestSingleUse(t *testing.T) {
|
||||
t.Errorf("%d: SingleUse.ReadUsingIndex doesn't return expected timestamp: %v", i, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Reading with limit.
|
||||
su := client.Single()
|
||||
const limit = 1
|
||||
gotRows, err := readAll(su.ReadWithOptions(ctx, "Singers", KeySets(Key{1}, Key{3}, Key{4}),
|
||||
[]string{"SingerId", "FirstName", "LastName"}, &ReadOptions{Limit: limit}))
|
||||
if err != nil {
|
||||
t.Errorf("SingleUse.ReadWithOptions returns error %v, want nil", err)
|
||||
}
|
||||
if got, want := len(gotRows), limit; got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test ReadOnlyTransaction. The testsuite is mostly like SingleUse, except it
|
||||
@@ -455,7 +469,7 @@ func TestReadOnlyTransaction(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("%d: ReadOnlyTransaction.Query returns error %v, want nil", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected result from ReadOnlyTransaction.Query: %v, want %v", i, got, test.want)
|
||||
}
|
||||
rts, err := ro.Timestamp()
|
||||
@@ -471,7 +485,7 @@ func TestReadOnlyTransaction(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("%d: ReadOnlyTransaction.Read returns error %v, want nil", i, err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected result from ReadOnlyTransaction.Read: %v, want %v", i, got, test.want)
|
||||
}
|
||||
rts, err = ro.Timestamp()
|
||||
@@ -507,7 +521,7 @@ func TestReadOnlyTransaction(t *testing.T) {
|
||||
t.Errorf("%d: got two read timestamps: %v, %v, want ReadOnlyTransaction to return always the same read timestamp", i, roTs, rts)
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%d: got unexpected results from ReadOnlyTransaction.ReadRow: %v, want %v", i, got, test.want)
|
||||
}
|
||||
// SingleUse.ReadUsingIndex
|
||||
@@ -529,7 +543,7 @@ func TestReadOnlyTransaction(t *testing.T) {
|
||||
}
|
||||
found := false
|
||||
for _, w := range test.want {
|
||||
if reflect.DeepEqual(g, w) {
|
||||
if testEqual(g, w) {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
@@ -587,7 +601,7 @@ func TestUpdateDuringRead(t *testing.T) {
|
||||
func TestReadWriteTransaction(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Give a longer deadline because of transaction backoffs.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
|
||||
defer cancel()
|
||||
client, _, tearDown := prepare(ctx, t, singerDBStatements)
|
||||
defer tearDown()
|
||||
@@ -832,7 +846,7 @@ func compareRows(iter *RowIterator, wantNums []int) (string, bool) {
|
||||
for _, r := range rows {
|
||||
got[r.Key] = r.StringValue
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
if !testEqual(got, want) {
|
||||
return fmt.Sprintf("got %v, want %v", got, want), false
|
||||
}
|
||||
return "", true
|
||||
@@ -842,7 +856,7 @@ func TestEarlyTimestamp(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test that we can get the timestamp from a read-only transaction as
|
||||
// soon as we have read at least one row.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
// Set up testing environment.
|
||||
client, _, tearDown := prepare(ctx, t, readDBStatements)
|
||||
@@ -1092,7 +1106,7 @@ func TestBasicTypes(t *testing.T) {
|
||||
}
|
||||
|
||||
// Check non-NaN cases.
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
if !testEqual(got, want) {
|
||||
t.Errorf("%d: col:%v val:%#v, got %#v, want %#v", i, test.col, test.val, got, want)
|
||||
continue
|
||||
}
|
||||
@@ -1164,7 +1178,7 @@ func TestStructTypes(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(want, s) {
|
||||
if !testEqual(want, s) {
|
||||
return fmt.Errorf("unexpected decoding result: %v, want %v", s, want)
|
||||
}
|
||||
return nil
|
||||
@@ -1235,12 +1249,54 @@ func TestQueryExpressions(t *testing.T) {
|
||||
if isNaN(got) && isNaN(test.want) {
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.want) {
|
||||
if !testEqual(got, test.want) {
|
||||
t.Errorf("%q\n got %#v\nwant %#v", test.expr, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
client, _, tearDown := prepare(ctx, t, singerDBStatements)
|
||||
defer tearDown()
|
||||
|
||||
accounts := []*Mutation{
|
||||
Insert("Accounts", []string{"AccountId", "Nickname", "Balance"}, []interface{}{int64(1), "Foo", int64(50)}),
|
||||
Insert("Accounts", []string{"AccountId", "Nickname", "Balance"}, []interface{}{int64(2), "Bar", int64(1)}),
|
||||
}
|
||||
if _, err := client.Apply(ctx, accounts, ApplyAtLeastOnce()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const sql = "SELECT Balance FROM Accounts"
|
||||
|
||||
qp, err := client.Single().AnalyzeQuery(ctx, Statement{sql, nil})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(qp.PlanNodes) == 0 {
|
||||
t.Error("got zero plan nodes, expected at least one")
|
||||
}
|
||||
|
||||
iter := client.Single().QueryWithStats(ctx, Statement{sql, nil})
|
||||
defer iter.Stop()
|
||||
for {
|
||||
_, err := iter.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if iter.QueryPlan == nil {
|
||||
t.Error("got nil QueryPlan, expected one")
|
||||
}
|
||||
if iter.QueryStats == nil {
|
||||
t.Error("got nil QueryStats, expected some")
|
||||
}
|
||||
}
|
||||
|
||||
func isNaN(x interface{}) bool {
|
||||
f, ok := x.(float64)
|
||||
if !ok {
|
||||
@@ -1260,7 +1316,7 @@ func TestInvalidDatabase(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := testutil.TokenSource(ctx, Scope)
|
||||
if ts == nil {
|
||||
t.Skip("Integration test skipped: cannot get service account credential from environment variable %v", "GCLOUD_TESTS_GOLANG_KEY")
|
||||
t.Skip("Integration test skipped: cannot get service account credential from environment variable GCLOUD_TESTS_GOLANG_KEY")
|
||||
}
|
||||
db := fmt.Sprintf("projects/%v/instances/%v/databases/invalid", testProjectID, testInstanceID)
|
||||
c, err := NewClient(ctx, db, option.WithTokenSource(ts))
|
||||
|
||||
Reference in New Issue
Block a user