Skip to content

Commit f4b4c94

Browse files
committed
Simplify test code
1 parent 8f9be56 commit f4b4c94

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

rest/importtest/import_test.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,24 @@ func TestImportFeed(t *testing.T) {
7474
}
7575

7676
func TestImportFeedWithRecursiveSyncFunction(t *testing.T) {
77-
7877
base.SkipImportTestsIfNotEnabled(t)
7978

80-
rtConfig := rest.RestTesterConfig{
79+
base.SetUpTestLogging(t, base.LevelDebug, base.KeyImport, base.KeyCRUD)
80+
81+
rt := rest.NewRestTester(t, &rest.RestTesterConfig{
8182
SyncFn: `function access(doc) { access("foo", "bar"); }`,
8283
AutoImport: base.Ptr(true),
83-
}
84-
85-
rt := rest.NewRestTester(t, &rtConfig)
84+
})
8685
defer rt.Close()
87-
dataStore := rt.GetSingleDataStore()
88-
89-
base.SetUpTestLogging(t, base.LevelDebug, base.KeyImport, base.KeyCRUD)
9086

9187
// Create doc via the SDK
9288
mobileKey := t.Name()
93-
mobileBody := make(map[string]interface{})
94-
mobileBody["channels"] = "ABC"
95-
_, err := dataStore.Add(mobileKey, 0, mobileBody)
96-
assert.NoError(t, err, "Error writing SDK doc")
89+
mobileBody := map[string]any{"channels": "ABC"}
90+
added, err := rt.GetSingleDataStore().Add(mobileKey, 0, mobileBody)
91+
require.NoError(t, err, "Error writing SDK doc")
92+
require.True(t, added)
9793

98-
// Wait for import
99-
err = rt.WaitForCondition(func() bool {
100-
return rt.GetDatabase().DbStats.SharedBucketImportStats.ImportErrorCount.Value() == 1
101-
})
102-
require.NoError(t, err)
94+
base.RequireWaitForStat(t, rt.GetDatabase().DbStats.SharedBucketImportStats.ImportErrorCount.Value, 1)
10395

10496
// Attempt to get the document via Sync Gateway.
10597
response := rt.SendAdminRequest("GET", "/{{.keyspace}}/"+mobileKey, "")

0 commit comments

Comments
 (0)