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

properly handle biri.Error #163

Merged
merged 4 commits into from
Nov 16, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added integration tests for deleting non-existing document case
arnitolog authored Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
weblate Weblate (bot)
commit 3caa316dc6d733c6ee0ab36e8cf8a79d623df6af
35 changes: 35 additions & 0 deletions internal/impl/opensearch/integration_test.go
Original file line number Diff line number Diff line change
@@ -451,6 +451,41 @@
resEqualsJSON(t, get, string(testMsg[i]))
}
}

// Test deleting a non-existing document
m2 := outputFromConf(t, `
index: test_conn_index
id: 'non-existing-id'
urls: %v
action: delete
`, urls)

require.NoError(t, m2.Connect(ctx))
defer func() {
require.NoError(t, m2.Close(ctx))
}()

require.Error(t, m2.WriteBatch(ctx, service.MessageBatch{
service.NewMessage([]byte{}),
}))

// Verify the document was not found
get, err := client.Do(ctx, osapi.DocumentGetReq{
Index: "test_conn_index",
DocumentID: "non-existing-id",
}, nil)
require.NoError(t, err)
if get.IsError() {
var respCode int

Check failure on line 479 in internal/impl/opensearch/integration_test.go

GitHub Actions / golangci-lint

S1021: should merge variable declaration with assignment on next line (gosimple)
respCode = get.StatusCode
if respCode == http.StatusNotFound {
// Document was not found, as expected
} else {
t.Errorf("Unexpected error deleting non-existing document: %d", respCode)
}
} else {
t.Errorf("Expected error deleting non-existing document")
}
}

func testOpenSearchBatchIDCollision(urls []string, client *os.Client, t *testing.T) {
Loading