Skip to content

Commit

Permalink
add test case for dropping collection deletes all documents
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyson committed Jul 10, 2024
1 parent 454d468 commit 58c3f4b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/collection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ defmodule CollectionTest do
ExTypesense.list_collection_aliases()
end

test "success: dropping collection deletes all documents", %{schema: schema} do
ExTypesense.create_collection(schema)

multiple_documents = %{
collection_name: "collection_companies",
documents: [
%{company_name: "Noogle, Inc.", company_id: 56, country: "AO"},
%{company_name: "Tikipedia", company_id: 62, country: "BD"}
]
}

assert {:ok, _} = ExTypesense.upsert_multiple_documents(multiple_documents)
assert %ExTypesense.Collection{} = ExTypesense.drop_collection(schema.name)
assert {:error, "Not Found"} = ExTypesense.get_document(schema.name, 1)
end

test "error: dropping unknown collection" do
collection_name = "unknown"
message = ~s(No collection with name `#{collection_name}` found.)
Expand Down

0 comments on commit 58c3f4b

Please sign in to comment.