22
33class QueryBuilderTest < ActiveSupport ::TestCase
44 test 'query builder trims spaces' do
5- expected = { 'from' => '0' , 'q' => 'blah' }
5+ expected = { 'from' => '0' , 'q' => 'blah' , 'index' => 'FAKE_TIMDEX_INDEX' }
66 search = { q : ' blah ' }
77 assert_equal ( expected , QueryBuilder . new ( search ) . query )
88 end
99
1010 test 'query builder handles supported fields' do
11- expected = { 'from' => '0' , 'q' => 'blah' , 'citation' => 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
11+ expected = { 'from' => '0' , 'q' => 'blah' ,
12+ 'citation' => 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
1213 'contributors' => 'Vonnegut, Kurt' , 'fundingInformation' => 'National Science Foundation' ,
1314 'identifiers' => 'doi://1234.123/123.123' , 'locations' => 'Cambridge, MA' ,
14- 'subjects' => 'Subjects are the worst' , 'title' => 'Hi I like titles' }
15+ 'subjects' => 'Subjects are the worst' , 'title' => 'Hi I like titles' , 'index' => 'FAKE_TIMDEX_INDEX' }
1516 search = {
1617 q : ' blah ' ,
1718 citation : 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
@@ -26,10 +27,11 @@ class QueryBuilderTest < ActiveSupport::TestCase
2627 end
2728
2829 test 'query builder ignores unsupported fields' do
29- expected = { 'from' => '0' , 'q' => 'blah' , 'citation' => 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
30+ expected = { 'from' => '0' , 'q' => 'blah' ,
31+ 'citation' => 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
3032 'contributors' => 'Vonnegut, Kurt' , 'fundingInformation' => 'National Science Foundation' ,
3133 'identifiers' => 'doi://1234.123/123.123' , 'locations' => 'Cambridge, MA' ,
32- 'subjects' => 'Subjects are the worst' , 'title' => 'Hi I like titles' }
34+ 'subjects' => 'Subjects are the worst' , 'title' => 'Hi I like titles' , 'index' => 'FAKE_TIMDEX_INDEX' }
3335 search = {
3436 q : ' blah ' ,
3537 citation : 'Citations are cool. Journal of cool citations. Vol 3, page 123.' ,
@@ -47,7 +49,7 @@ class QueryBuilderTest < ActiveSupport::TestCase
4749 test 'query builder ignores supported fields that were not included' do
4850 expected = { 'from' => '0' , 'q' => 'blah' , 'contributors' => 'Vonnegut, Kurt' ,
4951 'fundingInformation' => 'National Science Foundation' ,
50- 'identifiers' => 'doi://1234.123/123.123' }
52+ 'identifiers' => 'doi://1234.123/123.123' , 'index' => 'FAKE_TIMDEX_INDEX' }
5153 search = {
5254 q : ' blah ' ,
5355 contributors : 'Vonnegut, Kurt' ,
@@ -65,7 +67,9 @@ class QueryBuilderTest < ActiveSupport::TestCase
6567 end
6668
6769 test 'query builder index is nil if TIMDEX_INDEX not provided in env' do
68- search = { q : 'blah' }
69- assert_nil ( QueryBuilder . new ( search ) . query [ 'index' ] )
70+ ClimateControl . modify TIMDEX_INDEX : nil do
71+ search = { q : 'blah' }
72+ assert_nil ( QueryBuilder . new ( search ) . query [ 'index' ] )
73+ end
7074 end
7175end
0 commit comments