elasticsearch-test-runner 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a279ed35dcdcebb3992365f237f70fd6c1c9d8ee49e71d622d74a76280832203
4
- data.tar.gz: 3d7e8fd20126eda08aa0e452d4dd2806a143a9fa1a227206c157e7b42090406b
3
+ metadata.gz: 7452d0963f9177b56e8dbfdbe0ee2d779e4e733ecff9f21be71263611b8bfe4a
4
+ data.tar.gz: 72100349de35737ec78f2b6617b68fb9beef9a64d3ee59b3be06bfebd30cefd2
5
5
  SHA512:
6
- metadata.gz: af99ab6771f0dd2b94d600ef119c420e8a43ac06a7e06d5dc4414e31bb9ee96377689a52a98652db8069bd9a5181b892c11c973e186e868d44b020445d604175
7
- data.tar.gz: dd69419f48f9f895e9d9d2646e210f0746a5696d29f4695c3066988106590fa493dd89e98e57022be38c5e110a4c12b05e62e3eb582f2b1f2907842acc8923ab
6
+ metadata.gz: e2709d1814074c2b29ffb9ba9066a1003ea3f074aaa13f1ceac0534c41b5b97e37e87ee42ea4525f320bf0f5e1dcafc0a55197c70afb312fad61f3c5c2d93f74
7
+ data.tar.gz: b2c440af0a742182c36b1c53aae1db3adc2b52ce0930ab88383c62203c9358f2589e34265bcb0180da4db4179096f0780d4775aa5ddbbb5f3f90a36fdf862631
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0] - 2024-08-15
4
+
5
+ - Better display of action and response when `ENV['DEBUG']` is true.
6
+ - Checks for more error types when catching exceptions.
7
+ - Better matching for regular expressions.
8
+ - Refactors `set_param_variable` for better substitution.
9
+
10
+ ## [0.8.0] - 2024-08-14
11
+
12
+ - Adds support for variable keys (`$`).
13
+
3
14
  ## [0.7.0] - 2024-08-08
4
15
 
5
16
  - Improves test (file) name display
@@ -54,7 +54,7 @@ module Elasticsearch
54
54
  method = arrayed_method.last
55
55
  end
56
56
  @response = client.send(method.to_sym, process_params(params))
57
- puts @response if ENV['DEBUG']
57
+ puts "Action: #{action}\nResponse: #{@response}\n\n" if ENV['DEBUG']
58
58
  @response
59
59
  rescue StandardError => e
60
60
  raise e unless expected_exception?(catchable, e)
@@ -66,7 +66,7 @@ module Elasticsearch
66
66
  case error_type
67
67
  when 'request_timeout'
68
68
  e.is_a?(Elastic::Transport::Transport::Errors::RequestTimeout)
69
- when 'missing'
69
+ when 'missing', /resource_not_found_exception/
70
70
  e.is_a?(Elastic::Transport::Transport::Errors::NotFound)
71
71
  when 'conflict'
72
72
  e.is_a?(Elastic::Transport::Transport::Errors::Conflict)
@@ -85,6 +85,8 @@ module Elasticsearch
85
85
  e.is_a?(Elastic::Transport::Transport::Errors::BadRequest)
86
86
  when /NullPointerException/
87
87
  e.message =~ /\[400\]/
88
+ when /status_exception/
89
+ e.message =~ /\[409\]/
88
90
  else
89
91
  e.message =~ /#{error_type}/
90
92
  end
@@ -109,7 +111,9 @@ module Elasticsearch
109
111
  end
110
112
 
111
113
  def match_regexp(expected, result)
112
- expected.is_a?(String) && expected.match?(/^\//) && result.match?(Regexp.new(expected.gsub('/', '')))
114
+ expected.is_a?(String) &&
115
+ expected.match?(/^\//) &&
116
+ result.match?(Regexp.new(expected.gsub('/', '').strip))
113
117
  end
114
118
 
115
119
  def do_length(action)
@@ -176,13 +180,11 @@ module Elasticsearch
176
180
  # Given a key coming from a test definition, search the response body for a matching value.
177
181
  #
178
182
  def search_in_response(keys)
179
- if (match = /\$([a-z]+)/.match(keys))
180
- return @response.send(match[1])
181
- end
182
-
183
183
  if keys.include?('.')
184
184
  key = split_and_parse_key(keys)
185
185
  return find_value_in_document(key, @response.body)
186
+ elsif (match = /\$([a-z]+)/.match(keys))
187
+ return @response.send(match[1])
186
188
  end
187
189
 
188
190
  @response[keys]
@@ -202,7 +204,13 @@ module Elasticsearch
202
204
  end
203
205
 
204
206
  def set_param_variable(params, key, param)
205
- params[key] = instance_variable_get(param.gsub('$', '@')) if param.is_a?(String) && param.include?('$')
207
+ return unless param.is_a?(String) && param.include?("$")
208
+
209
+ # Param can be a single '$value' string or '{ something: $value }'
210
+ repleacable = param.match(/(\$[0-9a-z_-]+)/)[0]
211
+ value = instance_variable_get(repleacable.gsub("$", "@"))
212
+ content = param.gsub(repleacable, value)
213
+ params[key] = content
206
214
  end
207
215
 
208
216
  # Given a list of keys, find the value in a recursively nested document.
@@ -217,7 +225,9 @@ module Elasticsearch
217
225
  return document[chain[0]] unless chain.size > 1
218
226
 
219
227
  # a number can be a string key in a Hash or indicate an element in a list
220
- if document.is_a?(Hash)
228
+ if chain[0].is_a?(String) && chain[0].match?(/^\$/)
229
+ find_value_in_document(chain[1..], instance_variable_get("@#{chain[0].gsub('$', '')}"))
230
+ elsif document.is_a?(Hash)
221
231
  find_value_in_document(chain[1..], document[chain[0].to_s]) if document[chain[0].to_s]
222
232
  elsif document[chain[0]]
223
233
  find_value_in_document(chain[1..], document[chain[0]]) if document[chain[0]]
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Elasticsearch
21
21
  module Tests
22
- VERSION = '0.7.0'
22
+ VERSION = '0.9.0'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-test-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-08 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch