File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ def create(
5050 req . body = { }
5151 req . body [ "class" ] = class_name
5252 req . body [ "properties" ] = properties
53- req . body [ "tenant" ] = tenant unless tenant . blank ?
53+ req . body [ "tenant" ] = tenant unless tenant . nil ?
5454 req . body [ "id" ] = id unless id . nil?
5555 req . body [ "vector" ] = vector unless vector . nil?
5656 end
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ def create(
2727 description : nil ,
2828 properties : nil ,
2929 multi_tenant : nil ,
30+ auto_tenant_creation : nil ,
3031 vector_index_type : nil ,
3132 vector_index_config : nil ,
3233 vectorizer : nil ,
@@ -45,8 +46,9 @@ def create(
4546 req . body [ "properties" ] = properties unless properties . nil?
4647 if multi_tenant . is_a? ( Hash )
4748 req . body [ "multiTenancyConfig" ] = multi_tenant
48- elsif multi_tenant && !( multi_tenant . respond_to? ( :empty? ) && multi_tenant . empty? )
49- req . body [ "multiTenancyConfig" ] = { enabled : true }
49+ elsif !multi_tenant . nil?
50+ req . body [ "multiTenancyConfig" ] = { enabled : true }
51+ req . body [ "multiTenancyConfig" ] . merge! ( autoTenantCreation : true ) unless auto_tenant_creation . nil?
5052 end
5153 req . body [ "invertedIndexConfig" ] = inverted_index_config unless inverted_index_config . nil?
5254 req . body [ "replicationConfig" ] = replication_config unless replication_config . nil?
Original file line number Diff line number Diff line change 7676 )
7777 expect ( response . dig ( "class" ) ) . to eq ( "Question" )
7878 end
79+
80+ context "when auto_tenant_creation passed" do
81+ before do
82+ @captured_request = nil
83+ allow_any_instance_of ( Faraday ::Connection ) . to receive ( :post ) do |_ , path , &block |
84+ expect ( path ) . to eq ( "schema" )
85+ req = OpenStruct . new ( body : { } )
86+ block . call ( req )
87+ @captured_request = req
88+ response
89+ end
90+ end
91+
92+ it "sets up multiTenancyConfig with autoTenantCreation enabled" do
93+ schema . create (
94+ class_name : "Question" ,
95+ description : "Information from a Jeopardy! question" ,
96+ multi_tenant : true ,
97+ auto_tenant_creation : true
98+ )
99+
100+ expect ( @captured_request . body [ "multiTenancyConfig" ] ) . to eq ( { enabled : true , autoTenantCreation : true } )
101+ end
102+ end
79103 end
80104
81105 describe "#delete" do
You can’t perform that action at this time.
0 commit comments