mirror of
https://github.com/restic/restic.git
synced 2026-11-21 13:02:42 +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:
1 parent
b63de7c798
commit
2b39f9f4b2
3435 files changed
+1317989
-315639
No files matched your search
+62
-165
@@ -226,10 +226,7 @@ func TestIntegration_Get(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
doc := integrationColl(t).NewDoc()
|
||||
mustCreate("Get #1", t, doc, integrationTestMap)
|
||||
ds, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds := mustGet("Get #1", t, doc)
|
||||
if ds.CreateTime != ds.UpdateTime {
|
||||
t.Errorf("create time %s != update time %s", ds.CreateTime, ds.UpdateTime)
|
||||
}
|
||||
@@ -237,7 +234,19 @@ func TestIntegration_Get(t *testing.T) {
|
||||
if want := wantIntegrationTestMap; !testEqual(got, want) {
|
||||
t.Errorf("got\n%v\nwant\n%v", pretty.Value(got), pretty.Value(want))
|
||||
}
|
||||
_, err = integrationColl(t).NewDoc().Get(ctx)
|
||||
|
||||
doc = integrationColl(t).NewDoc()
|
||||
empty := map[string]interface{}{}
|
||||
mustCreate("Get empty", t, doc, empty)
|
||||
ds = mustGet("Get empty", t, doc)
|
||||
if ds.CreateTime != ds.UpdateTime {
|
||||
t.Errorf("create time %s != update time %s", ds.CreateTime, ds.UpdateTime)
|
||||
}
|
||||
if got, want := ds.Data(), empty; !testEqual(got, want) {
|
||||
t.Errorf("got\n%v\nwant\n%v", pretty.Value(got), pretty.Value(want))
|
||||
}
|
||||
|
||||
_, err := integrationColl(t).NewDoc().Get(ctx)
|
||||
codeEq(t, "Get on a missing doc", codes.NotFound, err)
|
||||
}
|
||||
|
||||
@@ -304,12 +313,8 @@ func TestIntegration_Set(t *testing.T) {
|
||||
if !wr1.UpdateTime.Before(wr2.UpdateTime) {
|
||||
t.Errorf("update time did not increase: old=%s, new=%s", wr1.UpdateTime, wr2.UpdateTime)
|
||||
}
|
||||
ds, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := ds.Data()
|
||||
if !testEqual(got, newData) {
|
||||
ds := mustGet("Set #1", t, doc)
|
||||
if got := ds.Data(); !testEqual(got, newData) {
|
||||
t.Errorf("got %v, want %v", got, newData)
|
||||
}
|
||||
|
||||
@@ -321,21 +326,17 @@ func TestIntegration_Set(t *testing.T) {
|
||||
// SetOptions:
|
||||
// Only fields mentioned in the Merge option will be changed.
|
||||
// In this case, "str" will not be changed to "1".
|
||||
wr3, err := doc.Set(ctx, newData, Merge("x", "y"))
|
||||
wr3, err := doc.Set(ctx, newData, Merge([]string{"x"}, []string{"y"}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err = doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got = ds.Data()
|
||||
ds = mustGet("Set #2", t, doc)
|
||||
want := map[string]interface{}{
|
||||
"str": "change",
|
||||
"x": "2",
|
||||
"y": "3",
|
||||
}
|
||||
if !testEqual(got, want) {
|
||||
if got := ds.Data(); !testEqual(got, want) {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
}
|
||||
if !wr2.UpdateTime.Before(wr3.UpdateTime) {
|
||||
@@ -348,17 +349,13 @@ func TestIntegration_Set(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err = doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got = ds.Data()
|
||||
ds = mustGet("Set #3", t, doc)
|
||||
want = map[string]interface{}{
|
||||
"str": "change",
|
||||
"x": "4",
|
||||
"y": "5",
|
||||
}
|
||||
if !testEqual(got, want) {
|
||||
if got := ds.Data(); !testEqual(got, want) {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
}
|
||||
if !wr3.UpdateTime.Before(wr4.UpdateTime) {
|
||||
@@ -392,100 +389,22 @@ func TestIntegration_Delete(t *testing.T) {
|
||||
er(doc.Delete(ctx, LastUpdateTime(wr.UpdateTime))))
|
||||
}
|
||||
|
||||
func TestIntegration_UpdateMap(t *testing.T) {
|
||||
func TestIntegration_Update(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
doc := integrationColl(t).NewDoc()
|
||||
mustCreate("UpdateMap", t, doc, integrationTestMap)
|
||||
um := map[string]interface{}{
|
||||
"bool": false,
|
||||
"time": 17,
|
||||
"null": Delete,
|
||||
"noSuchField": Delete, // deleting a non-existent field is a no-op
|
||||
mustCreate("Update", t, doc, integrationTestMap)
|
||||
fpus := []Update{
|
||||
{Path: "bool", Value: false},
|
||||
{Path: "time", Value: 17},
|
||||
{FieldPath: []string{"*", "`"}, Value: 18},
|
||||
{Path: "null", Value: Delete},
|
||||
{Path: "noSuchField", Value: Delete}, // deleting a non-existent field is a no-op
|
||||
}
|
||||
wr, err := doc.UpdateMap(ctx, um)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := ds.Data()
|
||||
want := copyMap(wantIntegrationTestMap)
|
||||
want["bool"] = false
|
||||
want["time"] = int64(17)
|
||||
delete(want, "null")
|
||||
if !testEqual(got, want) {
|
||||
t.Errorf("got\n%#v\nwant\n%#v", got, want)
|
||||
}
|
||||
|
||||
er := func(_ *WriteResult, err error) error { return err }
|
||||
codeEq(t, "UpdateMap on missing doc", codes.NotFound,
|
||||
er(integrationColl(t).NewDoc().UpdateMap(ctx, um)))
|
||||
codeEq(t, "UpdateMap with wrong LastUpdateTime", codes.FailedPrecondition,
|
||||
er(doc.UpdateMap(ctx, um, LastUpdateTime(wr.UpdateTime.Add(-time.Millisecond)))))
|
||||
codeEq(t, "UpdateMap with right LastUpdateTime", codes.OK,
|
||||
er(doc.UpdateMap(ctx, um, LastUpdateTime(wr.UpdateTime))))
|
||||
codeEq(t, "just server transform", codes.OK,
|
||||
er(doc.UpdateMap(ctx, map[string]interface{}{"a": ServerTimestamp})))
|
||||
}
|
||||
|
||||
func TestIntegration_UpdateStruct(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
doc := integrationColl(t).NewDoc()
|
||||
mustCreate("UpdateStruct", t, doc, integrationTestStruct)
|
||||
fields := []string{"Bool", "Time", "Null", "noSuchField"}
|
||||
wr, err := doc.UpdateStruct(ctx, fields,
|
||||
integrationTestStructType{
|
||||
Bool: false,
|
||||
Time: aTime2,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got integrationTestStructType
|
||||
if err := ds.DataTo(&got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := integrationTestStruct
|
||||
want.Bool = false
|
||||
want.Time = aTime2
|
||||
if !testEqual(got, want) {
|
||||
t.Errorf("got\n%#v\nwant\n%#v", got, want)
|
||||
}
|
||||
|
||||
er := func(_ *WriteResult, err error) error { return err }
|
||||
codeEq(t, "UpdateStruct on missing doc", codes.NotFound,
|
||||
er(integrationColl(t).NewDoc().UpdateStruct(ctx, fields, integrationTestStruct)))
|
||||
codeEq(t, "UpdateStruct with wrong LastUpdateTime", codes.FailedPrecondition,
|
||||
er(doc.UpdateStruct(ctx, fields, integrationTestStruct, LastUpdateTime(wr.UpdateTime.Add(-time.Millisecond)))))
|
||||
codeEq(t, "UpdateStruct with right LastUpdateTime", codes.OK,
|
||||
er(doc.UpdateStruct(ctx, fields, integrationTestStruct, LastUpdateTime(wr.UpdateTime))))
|
||||
}
|
||||
|
||||
func TestIntegration_UpdatePaths(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
doc := integrationColl(t).NewDoc()
|
||||
mustCreate("UpdatePaths", t, doc, integrationTestMap)
|
||||
fpus := []FieldPathUpdate{
|
||||
{Path: []string{"bool"}, Value: false},
|
||||
{Path: []string{"time"}, Value: 17},
|
||||
{Path: []string{"*", "`"}, Value: 18},
|
||||
{Path: []string{"null"}, Value: Delete},
|
||||
{Path: []string{"noSuchField"}, Value: Delete}, // deleting a non-existent field is a no-op
|
||||
}
|
||||
wr, err := doc.UpdatePaths(ctx, fpus)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err := doc.Get(ctx)
|
||||
wr, err := doc.Update(ctx, fpus)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds := mustGet("Update", t, doc)
|
||||
got := ds.Data()
|
||||
want := copyMap(wantIntegrationTestMap)
|
||||
want["bool"] = false
|
||||
@@ -498,12 +417,12 @@ func TestIntegration_UpdatePaths(t *testing.T) {
|
||||
|
||||
er := func(_ *WriteResult, err error) error { return err }
|
||||
|
||||
codeEq(t, "UpdatePaths on missing doc", codes.NotFound,
|
||||
er(integrationColl(t).NewDoc().UpdatePaths(ctx, fpus)))
|
||||
codeEq(t, "UpdatePaths with wrong LastUpdateTime", codes.FailedPrecondition,
|
||||
er(doc.UpdatePaths(ctx, fpus, LastUpdateTime(wr.UpdateTime.Add(-time.Millisecond)))))
|
||||
codeEq(t, "UpdatePaths with right LastUpdateTime", codes.OK,
|
||||
er(doc.UpdatePaths(ctx, fpus, LastUpdateTime(wr.UpdateTime))))
|
||||
codeEq(t, "Update on missing doc", codes.NotFound,
|
||||
er(integrationColl(t).NewDoc().Update(ctx, fpus)))
|
||||
codeEq(t, "Update with wrong LastUpdateTime", codes.FailedPrecondition,
|
||||
er(doc.Update(ctx, fpus, LastUpdateTime(wr.UpdateTime.Add(-time.Millisecond)))))
|
||||
codeEq(t, "Update with right LastUpdateTime", codes.OK,
|
||||
er(doc.Update(ctx, fpus, LastUpdateTime(wr.UpdateTime))))
|
||||
}
|
||||
|
||||
func TestIntegration_Collections(t *testing.T) {
|
||||
@@ -557,16 +476,12 @@ func TestIntegration_ServerTimestamp(t *testing.T) {
|
||||
D: map[string]interface{}{"x": ServerTimestamp},
|
||||
// E is unset, so will get the server timestamp.
|
||||
}
|
||||
ctx := context.Background()
|
||||
doc := integrationColl(t).NewDoc()
|
||||
// Bound times of the RPC, with some slack for clock skew.
|
||||
start := time.Now()
|
||||
mustCreate("ServerTimestamp", t, doc, data)
|
||||
end := time.Now()
|
||||
ds, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds := mustGet("ServerTimestamp", t, doc)
|
||||
var got S
|
||||
if err := ds.DataTo(&got); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -594,24 +509,18 @@ func TestIntegration_MergeServerTimestamp(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
docSnap, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
docSnap := mustGet("MergeST #1", t, doc)
|
||||
data1 := docSnap.Data()
|
||||
// Merge with a document with a different value of "a". However,
|
||||
// specify only "b" in the list of merge fields.
|
||||
_, err = doc.Set(ctx,
|
||||
map[string]interface{}{"a": 2, "b": ServerTimestamp},
|
||||
Merge("b"))
|
||||
Merge([]string{"b"}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The result should leave "a" unchanged, while "b" is updated.
|
||||
docSnap, err = doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
docSnap = mustGet("MergeST #2", t, doc)
|
||||
data2 := docSnap.Data()
|
||||
if got, want := data2["a"], data1["a"]; got != want {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
@@ -637,11 +546,7 @@ func TestIntegration_MergeNestedServerTimestamp(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
docSnap, err := doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data1 := docSnap.Data()
|
||||
data1 := mustGet("MergeNST #1", t, doc).Data()
|
||||
// Merge with a document with a different value of "a". However,
|
||||
// specify only "c.d" in the list of merge fields.
|
||||
_, err = doc.Set(ctx,
|
||||
@@ -650,16 +555,12 @@ func TestIntegration_MergeNestedServerTimestamp(t *testing.T) {
|
||||
"b": ServerTimestamp,
|
||||
"c": map[string]interface{}{"d": ServerTimestamp},
|
||||
},
|
||||
Merge("c.d"))
|
||||
Merge([]string{"c", "d"}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The result should leave "a" and "b" unchanged, while "c.d" is updated.
|
||||
docSnap, err = doc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data2 := docSnap.Data()
|
||||
data2 := mustGet("MergeNST #2", t, doc).Data()
|
||||
if got, want := data2["a"], data1["a"]; got != want {
|
||||
t.Errorf("a: got %v, want %v", got, want)
|
||||
}
|
||||
@@ -682,8 +583,8 @@ func TestIntegration_WriteBatch(t *testing.T) {
|
||||
doc2 := iColl.NewDoc()
|
||||
b.Create(doc1, integrationTestMap)
|
||||
b.Set(doc2, integrationTestMap)
|
||||
b.UpdateMap(doc1, map[string]interface{}{"bool": false})
|
||||
b.UpdateMap(doc1, map[string]interface{}{"str": Delete})
|
||||
b.Update(doc1, []Update{{Path: "bool", Value: false}})
|
||||
b.Update(doc1, []Update{{Path: "str", Value: Delete}})
|
||||
|
||||
wrs, err := b.Commit(ctx)
|
||||
if err != nil {
|
||||
@@ -692,22 +593,14 @@ func TestIntegration_WriteBatch(t *testing.T) {
|
||||
if got, want := len(wrs), 4; got != want {
|
||||
t.Fatalf("got %d WriteResults, want %d", got, want)
|
||||
}
|
||||
ds, err := doc1.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got1 := ds.Data()
|
||||
got1 := mustGet("WriteBatch #1", t, doc1).Data()
|
||||
want := copyMap(wantIntegrationTestMap)
|
||||
want["bool"] = false
|
||||
delete(want, "str")
|
||||
if !testEqual(got1, want) {
|
||||
t.Errorf("got\n%#v\nwant\n%#v", got1, want)
|
||||
}
|
||||
ds, err = doc2.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got2 := ds.Data()
|
||||
got2 := mustGet("WriteBatch #2", t, doc2).Data()
|
||||
if !testEqual(got2, wantIntegrationTestMap) {
|
||||
t.Errorf("got\n%#v\nwant\n%#v", got2, wantIntegrationTestMap)
|
||||
}
|
||||
@@ -878,14 +771,13 @@ func TestIntegration_RunTransaction(t *testing.T) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.UpdateStruct(patDoc, []string{"Score"},
|
||||
Player{Score: int(score.(int64) + 7)})
|
||||
err = tx.Update(patDoc, []Update{{Path: "Score", Value: int(score.(int64) + 7)}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Since the Star field is called "*", we must use UpdatePaths to change it.
|
||||
err = tx.UpdatePaths(patDoc,
|
||||
[]FieldPathUpdate{{Path: []string{"*"}, Value: !star.(bool)}})
|
||||
// Since the Star field is called "*", we must use Update to change it.
|
||||
err = tx.Update(patDoc,
|
||||
[]Update{{FieldPath: []string{"*"}, Value: !star.(bool)}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -896,10 +788,7 @@ func TestIntegration_RunTransaction(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds, err := patDoc.Get(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds := mustGet("RunTransaction", t, patDoc)
|
||||
var got Player
|
||||
if err := ds.DataTo(&got); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -938,6 +827,14 @@ func mustCreate(msg string, t *testing.T, doc *DocumentRef, data interface{}) *W
|
||||
return wr
|
||||
}
|
||||
|
||||
func mustGet(msg string, t *testing.T, doc *DocumentRef) *DocumentSnapshot {
|
||||
d, err := doc.Get(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("%s: getting: %v", msg, err)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func copyMap(m map[string]interface{}) map[string]interface{} {
|
||||
c := map[string]interface{}{}
|
||||
for k, v := range m {
|
||||
@@ -948,7 +845,7 @@ func copyMap(m map[string]interface{}) map[string]interface{} {
|
||||
|
||||
func checkTimeBetween(t *testing.T, got, low, high time.Time) {
|
||||
// Allow slack for clock skew.
|
||||
const slack = 2 * time.Second
|
||||
const slack = 4 * time.Second
|
||||
low = low.Add(-slack)
|
||||
high = high.Add(slack)
|
||||
if got.Before(low) || got.After(high) {
|
||||
|
||||
Reference in new issue
Block a user