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