elasticsearch-test-runner 0.2.0 โ†’ 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0db95fdc124cceab0a7c1ef1de55d383a1f8025c25e12f05de3b0a3ff5bf49e
4
- data.tar.gz: 3a6763721958e62945c886386aa8ebd65993522f71b29486a8911d2c0f02e520
3
+ metadata.gz: 371dabd8cff033ef7d2656b874f4fcb5fd63f5bde3093d5ce1ee830e9e253187
4
+ data.tar.gz: 43006ff9d74aea61684af8abc8e660099c009a1e7293d489c5796887efb9756e
5
5
  SHA512:
6
- metadata.gz: f5973e272d04b24f36e5201c0f3329bea7f5dd7c5be86d89cfb08c6f3cd717c4ce623065e7aa9456cdf9b26480a44ff4b763df2e783d16d2c14d3335d8164c6a
7
- data.tar.gz: beb4c948667c664376306d77fe49e53467b99ca1d38a15c08dcde06abded7fb63005fb5d3a00017e3e46f19cc87338284150dfcde5ec8caa701912dedc6dea76
6
+ metadata.gz: b927b0015746d72b19d26ac3812243f4b91df653d785b924a58a8dd219608358ed1e3dbbf6b76af3ce240b4d3289371ded4615e38f8d891438b929311b9abe77
7
+ data.tar.gz: a5b2ef6724092c8d6d4a39893346d233ca2c170121d59778ef4f85fea66e339e4db33ccfe40deac23d1d9b4f55dc306ffaa7c4ad5ba4bee8288b53887870b3b6
data/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2024-06-27
4
+
5
+ - Fixes in error handling.
6
+
7
+ ## [0.3.0] - 2024-06-27
8
+
9
+ - Fixes exit code.
10
+ - Refactors error handling for more detailed information.
11
+
3
12
  ## [0.2.0] - 2024-06-25
4
13
 
5
- - Renames gemspec from elasticsearch-tests to elasticsearch-test-runner
6
- - Adds ability to run individual test files or directories
14
+ - Renames gemspec from elasticsearch-tests to elasticsearch-test-runner.
15
+ - Adds ability to run individual test files or directories.
7
16
 
8
17
  ## [0.1.1] - 2024-06-20
9
18
 
@@ -19,5 +19,16 @@ module Elasticsearch
19
19
  module Tests
20
20
  class TestFailure < StandardError; end
21
21
  class TestError < StandardError; end
22
+
23
+ # Class to track exactly which action errored
24
+ class ActionError < StandardError
25
+ attr_reader :test_file, :action
26
+
27
+ def initialize(message, test_file, action)
28
+ super(message)
29
+ @test_file = test_file
30
+ @action = action
31
+ end
32
+ end
22
33
  end
23
34
  end
@@ -34,18 +34,21 @@ module Elasticsearch
34
34
  def print_failure(action, response)
35
35
  puts "๐Ÿ”ด #{@file} #{@title} failed"
36
36
  puts "Expected result: #{action}" # TODO: Show match/length differently
37
- if response.is_a?(ElasticsearchServerless::API::Response)
37
+ if defined?(ElasticsearchServerless) &&
38
+ response.is_a?(ElasticsearchServerless::API::Response) ||
39
+ defined?(Elasticsearch::API) && response.is_a?(Elasticsearch::API::Response)
38
40
  puts 'Response:'
39
41
  pp response.body
40
42
  else
41
43
  pp response
42
44
  end
43
- raise Elasticsearch::Tests::TestFailure
45
+ raise Elasticsearch::Tests::ActionError.new(response.body, @file, action)
44
46
  end
45
47
 
46
48
  def print_match_failure(action)
47
49
  keys = action['match'].keys.first
48
50
  value = action['match'].values.first
51
+
49
52
  message = <<~MSG
50
53
  ๐Ÿ”ด #{@file} #{@title} failed
51
54
  Expected: { #{keys}: #{value} }
@@ -65,7 +68,9 @@ module Elasticsearch
65
68
  def self.display_errors(errors)
66
69
  puts "+++ โŒ Errors/Failures: #{errors.count}"
67
70
  errors.map do |error|
68
- puts "* Test: #{error[:file]}\n #{error[:error].message}"
71
+ puts "๐Ÿงช Test: #{error[:file]}"
72
+ puts "โ–ถ Action: #{error[:action].first}" if error[:action]
73
+ puts "๐Ÿ”ฌ #{error[:error].message}"
69
74
  pp error[:error].backtrace.join("$/\n") if ENV['DEBUG']
70
75
  puts
71
76
  end
@@ -16,6 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  require_relative 'code_runner'
19
+ require_relative 'errors'
19
20
 
20
21
  module Elasticsearch
21
22
  module Tests
@@ -70,6 +71,8 @@ module Elasticsearch
70
71
  when 'gt', 'gte', 'lt', 'lte'
71
72
  compare(action)
72
73
  end
74
+ rescue StandardError => e
75
+ raise ActionError.new(e.message, @file, action)
73
76
  end
74
77
 
75
78
  def run_setup
@@ -41,6 +41,11 @@ module Elasticsearch
41
41
  run_the_tests
42
42
  Elasticsearch::Tests::Printer::display_errors(@errors) unless @errors.empty?
43
43
  Elasticsearch::Tests::Printer::display_summary(@tests_count, @errors.count, @start_time)
44
+ if @errors.empty?
45
+ exit 0
46
+ else
47
+ exit 1
48
+ end
44
49
  end
45
50
 
46
51
  def run_the_tests
@@ -54,6 +59,9 @@ module Elasticsearch
54
59
  @errors << { error: e, file: test_file }
55
60
  @logger.warn("YAML error in #{test_file}")
56
61
  @logger.warn e
62
+ rescue ActionError => e
63
+ @errors << { error: e, file: test_file, action: e.action }
64
+ @logger.debug e
57
65
  rescue StandardError => e
58
66
  @errors << { error: e, file: test_file }
59
67
  @logger.debug e
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Elasticsearch
21
21
  module Tests
22
- VERSION = '0.2.0'
22
+ VERSION = '0.3.1'
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.2.0
4
+ version: 0.3.1
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-06-25 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch