Skip to content

Commit

Permalink
[API] Test Runner: Refactors test_file to support new version skip fo…
Browse files Browse the repository at this point in the history
…rmat for tests
  • Loading branch information
picandocodigo committed Sep 27, 2023
1 parent 1c80003 commit 26f5f58
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions elasticsearch-api/api-spec-testing/test_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ def skip_entire_test_file?(file_name)
def skip_version?(client, skip_definition)
return true if skip_definition.fetch('version', '').include? 'all'

range_partition = /\s*-\s*/
return unless (versions = skip_definition['version'])

low, high = __parse_versions(versions.partition(range_partition))
low, high = __parse_versions(versions)
range = low..high
begin
server_version = client.info['version']['number']
Expand All @@ -90,7 +89,13 @@ def skip_version?(client, skip_definition)
end

def __parse_versions(versions)
versions = versions.split('-') if versions.is_a? String
if versions.count('-') == 2
versions = versions.gsub(/\s/, '').gsub(/-/, '').split(',')
else
range_partition = /\s*-\s*/
versions = versions.partition(range_partition)
versions = versions.split('-') if versions.is_a? String
end

low = (['', nil].include? versions[0]) ? '0' : versions[0]
high = (['', nil].include? versions[2]) ? '9999' : versions[2]
Expand Down

0 comments on commit 26f5f58

Please sign in to comment.