11defmodule JoinTest do
22 use ExUnit.Case , async: true
33
4- alias OpenApiTypesense.ApiResponse
54 alias OpenApiTypesense.Collections
65 alias OpenApiTypesense.Documents
76 alias OpenApiTypesense.MultiSearchResult
@@ -45,7 +44,7 @@ defmodule JoinTest do
4544 }
4645
4746 product_schema = % {
48- name: "products " ,
47+ name: "join_products " ,
4948 fields: [
5049 % { name: "product_id" , type: "string" } ,
5150 % { name: "product_name" , type: "string" } ,
@@ -58,7 +57,7 @@ defmodule JoinTest do
5857 fields: [
5958 % { name: "title" , type: "string" } ,
6059 % { name: "price" , type: "float" } ,
61- % { name: "product_id" , type: "string" , reference: "products .product_id" }
60+ % { name: "product_id" , type: "string" , reference: "join_products .product_id" }
6261 ]
6362 }
6463
@@ -84,7 +83,7 @@ defmodule JoinTest do
8483 fields: [
8584 % { name: "customer_id" , type: "string" } ,
8685 % { name: "custom_price" , type: "float" } ,
87- % { name: "product_id" , type: "string" , reference: "products .product_id" }
86+ % { name: "product_id" , type: "string" , reference: "join_products .product_id" }
8887 ]
8988 }
9089
@@ -113,18 +112,21 @@ defmodule JoinTest do
113112 ]
114113 }
115114
116- { :ok , _ } = Collections . create_collection ( author_schema )
117- { :ok , _ } = Collections . create_collection ( book_schema )
118- { :ok , _ } = Collections . create_collection ( customer_schema )
119- { :ok , _ } = Collections . create_collection ( order_schema )
120- { :ok , _ } = Collections . create_collection ( product_schema )
121- { :ok , _ } = Collections . create_collection ( product_variant_schema )
122- { :ok , _ } = Collections . create_collection ( retailer_schema )
123- { :ok , _ } = Collections . create_collection ( inventory_schema )
124- { :ok , _ } = Collections . create_collection ( customer_product_prices_schema )
125- { :ok , _ } = Collections . create_collection ( document_schema )
126- { :ok , _ } = Collections . create_collection ( user_schema )
127- { :ok , _ } = Collections . create_collection ( user_doc_access_schema )
115+ [
116+ author_schema ,
117+ book_schema ,
118+ customer_schema ,
119+ order_schema ,
120+ product_schema ,
121+ product_variant_schema ,
122+ retailer_schema ,
123+ inventory_schema ,
124+ customer_product_prices_schema ,
125+ document_schema ,
126+ user_schema ,
127+ user_doc_access_schema
128+ ]
129+ |> Enum . each ( & Collections . create_collection / 1 )
128130
129131 [
130132 % {
@@ -323,18 +325,21 @@ defmodule JoinTest do
323325 end )
324326
325327 on_exit ( fn ->
326- { :ok , _ } = Collections . delete_collection ( author_schema . name )
327- { :ok , _ } = Collections . delete_collection ( book_schema . name )
328- { :ok , _ } = Collections . delete_collection ( customer_schema . name )
329- { :ok , _ } = Collections . delete_collection ( order_schema . name )
330- { :ok , _ } = Collections . delete_collection ( product_schema . name )
331- { :ok , _ } = Collections . delete_collection ( product_variant_schema . name )
332- { :ok , _ } = Collections . delete_collection ( retailer_schema . name )
333- { :ok , _ } = Collections . delete_collection ( inventory_schema . name )
334- { :ok , _ } = Collections . delete_collection ( customer_product_prices_schema . name )
335- { :ok , _ } = Collections . delete_collection ( document_schema . name )
336- { :ok , _ } = Collections . delete_collection ( user_schema . name )
337- { :ok , _ } = Collections . delete_collection ( user_doc_access_schema . name )
328+ [
329+ author_schema . name ,
330+ book_schema . name ,
331+ customer_schema . name ,
332+ order_schema . name ,
333+ product_schema . name ,
334+ product_variant_schema . name ,
335+ retailer_schema . name ,
336+ inventory_schema . name ,
337+ customer_product_prices_schema . name ,
338+ document_schema . name ,
339+ user_schema . name ,
340+ user_doc_access_schema . name
341+ ]
342+ |> Enum . each ( & Collections . delete_collection / 1 )
338343 end )
339344
340345 :ok
@@ -437,12 +442,12 @@ defmodule JoinTest do
437442 searches: [
438443 % {
439444 q: "*" ,
440- collection: "products " ,
445+ collection: "join_products " ,
441446 filter_by: "$customer_product_prices(customer_id:=1)"
442447 } ,
443448 % {
444449 q: "*" ,
445- collection: "products " ,
450+ collection: "join_products " ,
446451 filter_by: "$customer_product_prices(customer_id:=1 && custom_price:<=100)"
447452 }
448453 ]
@@ -626,7 +631,7 @@ defmodule JoinTest do
626631 ]
627632 }
628633 ]
629- } } = Documents . search ( "products " , opts )
634+ } } = Documents . search ( "join_products " , opts )
630635 end
631636
632637 @ tag [ "27.1": true , "27.0": true , "26.0": true ]
@@ -660,6 +665,6 @@ defmodule JoinTest do
660665 }
661666 }
662667 ]
663- } } = Documents . search ( "products " , opts )
668+ } } = Documents . search ( "join_products " , opts )
664669 end
665670end
0 commit comments