Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow tests to pass with SG_TEST_USE_XATTRS=false #6827

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions rest/diagnostic_doc_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ func TestGetAlldocChannels(t *testing.T) {
}

func TestGetDocDryRuns(t *testing.T) {
if !base.UnitTestUrlIsWalrus() {
t.Skip("This test asserts on an error message that will not be the same without walrus")
}
base.SkipImportTestsIfNotEnabled(t)
rt := NewRestTester(t, &RestTesterConfig{PersistentConfig: true})
defer rt.Close()
bucket := rt.Bucket().GetName()
Expand Down Expand Up @@ -106,36 +104,36 @@ func TestGetDocDryRuns(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, respMap.Exception, "403 user num too low")

response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id=doc"), `{"user":{"num":150}, "channel":"abc"}`)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=doc", `{"user":{"num":150}, "channel":"abc"}`)
RequireStatus(t, response, http.StatusOK)
var newrespMap SyncFnDryRun
err = json.Unmarshal(response.BodyBytes(), &newrespMap)
assert.NoError(t, err)
assert.Equal(t, newrespMap.Exception, "TypeError: Cannot access member '0' of undefined")

response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id=doc"), `{"user":{"num":120, "name":["user2"]}, "channel":"channel2"}`)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=doc", `{"user":{"num":120, "name":["user2"]}, "channel":"channel2"}`)
RequireStatus(t, response, http.StatusOK)

err = json.Unmarshal(response.BodyBytes(), &respMap)
assert.NoError(t, err)
assert.Equal(t, respMap.Access, channels.AccessMap{"user1": channels.BaseSetOf(t, "channel2")})

// get doc from bucket with no body provided
response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id=doc"), ``)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=doc", ``)
RequireStatus(t, response, http.StatusOK)
err = json.Unmarshal(response.BodyBytes(), &respMap)
assert.NoError(t, err)
assert.Equal(t, respMap.Access, channels.AccessMap{"user1": channels.BaseSetOf(t, "channel1")})

// Get doc that doesnt exist, will error
response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id=doc404"), ``)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=doc404", ``)
RequireStatus(t, response, http.StatusNotFound)
err = json.Unmarshal(response.BodyBytes(), &respMap)
assert.NoError(t, err)
assert.Equal(t, respMap.Exception, "")

// no doc id no body, will error
response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id="), ``)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=", ``)
RequireStatus(t, response, http.StatusInternalServerError)

// Import filter import=false and type error
Expand Down Expand Up @@ -181,7 +179,11 @@ func TestGetDocDryRuns(t *testing.T) {
RequireStatus(t, response, http.StatusOK)
err = json.Unmarshal(response.BodyBytes(), &respMap2)
assert.NoError(t, err)
assert.Equal(t, respMap2.Error, "key \"doc404\" missing")
if base.UnitTestUrlIsWalrus() {
assert.Equal(t, respMap2.Error, `key "doc404" missing`)
} else {
assert.Contains(t, respMap2.Error, "<ud>doc404</ud>: Not Found")
}
assert.False(t, respMap2.ShouldImport)

// Import filter get doc from bucket error body provided
Expand All @@ -202,7 +204,7 @@ func TestGetDocDryRuns(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, respMap.Channels.ToArray(), []string{"channel2"})

response = rt.SendDiagnosticRequest("GET", fmt.Sprintf("/{{.keyspace}}/_sync?doc_id=doc22"), `{"channel":"chanNew"}`)
response = rt.SendDiagnosticRequest("GET", "/{{.keyspace}}/_sync?doc_id=doc22", `{"channel":"chanNew"}`)
RequireStatus(t, response, http.StatusOK)
err = json.Unmarshal(response.BodyBytes(), &newrespMap)
assert.NoError(t, err)
Expand Down
Loading