class Egis::Testing::TestingMode
@!visibility private
Attributes
client[R]
output_downloader[R]
s3_bucket[R]
s3_location_parser[R]
test_id[R]
Public Class Methods
new(test_id, s3_bucket, client: Egis::Client.new, output_downloader: Egis::OutputDownloader.new(client.aws_s3_client), s3_location_parser: Egis::S3LocationParser.new)
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 7 def initialize(test_id, s3_bucket, client: Egis::Client.new, output_downloader: Egis::OutputDownloader.new(client.aws_s3_client), s3_location_parser: Egis::S3LocationParser.new) @test_id = test_id @s3_bucket = s3_bucket @dirty = false @client = client @output_downloader = output_downloader @s3_location_parser = s3_location_parser end
Public Instance Methods
async(_async_flag)
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 33 def async(_async_flag) dirty! false end
cleanup()
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 39 def cleanup remove_test_databases if dirty? end
database_name(name)
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 27 def database_name(name) dirty! "#{test_id}_#{name}" end
s3_path(s3_url)
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 19 def s3_path(s3_url) dirty! bucket, key = s3_location_parser.parse_url(s3_url) "s3://#{s3_bucket}/#{test_id}/#{bucket}/#{key}" end
Private Instance Methods
dirty!()
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 53 def dirty! @dirty = true end
dirty?()
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 57 def dirty? @dirty end
remove_test_databases()
click to toggle source
# File lib/egis/testing/testing_mode.rb, line 47 def remove_test_databases result = client.execute_query("SHOW DATABASES LIKE '#{test_id}.*';", async: false) query_result = output_downloader.download(result.output_location) query_result.flatten.each { |database| client.database(database).drop } end