This repository was archived by the owner on Jan 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,5 +167,70 @@ def schema(kind)
167167 end
168168 end
169169 end
170+
171+ [ "exact" , "range" ] . each do |input_kind |
172+ context "given a schema with a #{ input_kind } index" do
173+ def schema ( kind )
174+ mapping = {
175+ "kind" => kind ,
176+ "field" => "title" ,
177+ "unique" => true
178+ }
179+
180+ {
181+ "type" => { "title" => "string" } ,
182+ "indexes" => {
183+ "exactTitle" => mapping ,
184+ } ,
185+ }
186+ end
187+
188+ it "can specify field as unique" do
189+ schema = schema ( input_kind )
190+
191+ expect ( rpc ) . to receive ( :create_collection ) . with (
192+ anything ,
193+ anything ,
194+ array_including ( hash_including ( mapping : hash_including ( "unique" => true ) ) )
195+ )
196+
197+ client . create_collection ( "name" , schema )
198+ end
199+ end
200+ end
201+
202+ [
203+ "match" ,
204+ "ore-match" ,
205+ "filter-match" ,
206+ "field-dynamic-match" ,
207+ "field-dynamic-filter-match" ,
208+ "field-dynamic-ore-match" ,
209+ "dynamic-match" ,
210+ "dynamic-filter-match" ,
211+ "dynamic-ore-match" ] . each do |input_kind |
212+ context "given a schema with a #{ input_kind } index" do
213+ def schema ( kind )
214+ mapping = {
215+ "kind" => kind ,
216+ "field" => "title" ,
217+ "unique" => true
218+ }
219+
220+ {
221+ "type" => { "title" => "string" } ,
222+ "indexes" => {
223+ "title" => mapping ,
224+ } ,
225+ }
226+ end
227+
228+ it "can not specify field as unique" do
229+ schema = schema ( input_kind )
230+
231+ expect { client . create_collection ( "name" , schema ) } . to raise_error ( CipherStash ::Client ::Error ::InvalidSchemaError )
232+ end
233+ end
234+ end
170235 end
171- end
236+ end
You can’t perform that action at this time.
0 commit comments