Skip to content

Commit

Permalink
test_api: added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
os-rss committed Aug 14, 2023
1 parent a9f7f81 commit 058babe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/datastore/datastore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function query(queries::AbstractVector{Query})::Vector{QueryResult}
end

"""
Removes documents by ids, filter or all togather
Removes documents by ids, filter or all together
Multiple parameters can be used at once.
Returns whether the operation was successful.
Expand Down
6 changes: 6 additions & 0 deletions test/test_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include("helpers/mocking.jl")
apply(patch) do
req = HTTP.Messages.Request()

# Create a set of empty documents with known ids.
documents = map(1:10) do id
GptSearchPlugin.AppServer.Document(
id = string(id),
Expand All @@ -25,6 +26,8 @@ apply(patch) do
@test !isnothing(upsert_response) && !isnothing(upsert_response.ids)
@test isempty(intersect(documents, upsert_response.ids))

# Check that we have a document in a storage with a known id.
# Suggest we have a dummy storage where we search by id only, without embedding.
query_doc_id = string(last(documents).id)
query_request = GptSearchPlugin.AppServer.QueryRequest(
queries = [GptSearchPlugin.AppServer.Query(query = query_doc_id)]
Expand All @@ -35,18 +38,21 @@ apply(patch) do
query_result = first(query_response.results)
@test !isempty(query_result.results) && isequal(first(query_result.results).id, query_doc_id)

# Delete some documents.
request = GptSearchPlugin.AppServer.DeleteRequest(
ids = [query_doc_id]
)
delete_response = GptSearchPlugin.AppServer.delete_docs(req, request)
@test !isnothing(delete_response) && delete_response.success

# Delete all documents.
request = GptSearchPlugin.AppServer.DeleteRequest(
delete_all = true
)
delete_response = GptSearchPlugin.AppServer.delete_docs(req, request)
@test !isnothing(delete_response) && delete_response.success

# Finally check that we have nothing.
query_response = GptSearchPlugin.AppServer.query_post(req, query_request)
@test !isnothing(query_response) && !isnothing(query_response.results) && isempty(query_response.results)
end

0 comments on commit 058babe

Please sign in to comment.