From 58c3f4bc80e17f96a9fff521a123b6150222e669 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Wed, 10 Jul 2024 18:43:26 +0800 Subject: [PATCH] add test case for dropping collection deletes all documents --- test/collection_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/collection_test.exs b/test/collection_test.exs index c0ac8d5..91a1f7a 100644 --- a/test/collection_test.exs +++ b/test/collection_test.exs @@ -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.)