Skip to content

Commit

Permalink
testing: add basic sync test to test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 3, 2019
1 parent 2b236db commit 8ddf6ad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/basic_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,36 @@ func SubtestManyKeysAndQuery(t *testing.T, ds dstore.Datastore) {
subtestQuery(t, ds, dsq.Query{KeysOnly: true}, 100)
}

func SubtestBasicSync(t *testing.T, ds dstore.Datastore) {
if err := ds.Sync(dstore.NewKey("foo")); err != nil {
t.Fatal(err)
}

if err := ds.Put(dstore.NewKey("/foo"), []byte("foo")); err != nil {
t.Fatal(err)
}

if err := ds.Sync(dstore.NewKey("/foo")); err != nil {
t.Fatal(err)
}

if err := ds.Put(dstore.NewKey("/foo/bar"), []byte("bar")); err != nil {
t.Fatal(err)
}

if err := ds.Sync(dstore.NewKey("/foo")); err != nil {
t.Fatal(err)
}

if err := ds.Sync(dstore.NewKey("/foo/bar")); err != nil {
t.Fatal(err)
}

if err := ds.Sync(dstore.NewKey("")); err != nil {
t.Fatal(err)
}
}

// need a custom test filter to test the "fallback" filter case for unknown
// filters.
type testFilter struct{}
Expand Down
1 change: 1 addition & 0 deletions test/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var BasicSubtests = []func(t *testing.T, ds dstore.Datastore){
SubtestFilter,
SubtestManyKeysAndQuery,
SubtestReturnSizes,
SubtestBasicSync,
}

// BatchSubtests is a list of all basic batching datastore tests.
Expand Down

0 comments on commit 8ddf6ad

Please sign in to comment.