File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,37 @@ def typesense_healthy?(host = 'localhost', port = 8108)
3434 false
3535end
3636
37+ def typesense_version
38+ WebMock . allow_net_connect!
39+ conn = Faraday . new ( 'http://localhost:8108' )
40+ response = conn . get ( '/debug' ) do |req |
41+ req . headers [ 'X-TYPESENSE-API-KEY' ] = 'xyz'
42+ end
43+
44+ if response . status == 200 && !response . body . empty?
45+ debug_info = JSON . parse ( response . body )
46+ debug_info [ 'version' ]
47+ end
48+ rescue StandardError
49+ nil
50+ ensure
51+ WebMock . disable_net_connect! ( allow_localhost : true )
52+ end
53+
54+ def typesense_v30_or_above?
55+ version = typesense_version
56+ return false unless version
57+
58+ return true if version == 'nightly'
59+
60+ if version . match ( /^v(\d +)/ )
61+ major_version = Regexp . last_match ( 1 ) . to_i
62+ return major_version >= 30
63+ end
64+
65+ false
66+ end
67+
3768def ensure_typesense_running
3869 if typesense_healthy?
3970 puts '✅ Typesense is already running and healthy, ready for use in integration tests'
@@ -96,7 +127,6 @@ def stop_typesense_if_started
96127
97128 config . before ( :suite ) do
98129 ensure_typesense_running
99- WebMock . disable_net_connect!
100130 end
101131
102132 config . after ( :suite ) do
You can’t perform that action at this time.
0 commit comments