Module: Elasticsearch::Tests::Downloader

Defined in:
lib/elasticsearch/tests/downloader.rb

Overview

Module for downloading the test files

Constant Summary collapse

FILENAME =
'tests.tar.gz'.freeze

Class Method Summary collapse

Class Method Details

.download_tests(url) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/elasticsearch/tests/downloader.rb', line 40

def download_tests(url)
  File.open(FILENAME, 'w') do |downloaded_file|
    uri = URI.parse(url)
    uri.open('Accept' => 'application/vnd.github+json') do |artifact_file|
      downloaded_file.write(artifact_file.read)
    end
  end
  File.exist?(FILENAME)
end

.run(path, branch = 'main') ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/elasticsearch/tests/downloader.rb', line 27

def run(path, branch = 'main')
  delete_files(path)
  url = "https://api.github.com/repos/elastic/serverless-clients-tests/tarball/#{branch}"
  if download_tests(url)
    puts "Successfully downloaded #{FILENAME}"
  else
    warn "[!] Couldn't download #{FILENAME}"
    return
  end
  untar_file(path)
  File.delete(FILENAME)
end