Commit d50c4078 authored by Micaël Bergeron's avatar Micaël Bergeron

apply feedback from review

parent f71fbe7a
......@@ -64,8 +64,7 @@ module Pseudonymizer
private
def output_filename(basename = nil, ext = "csv.gz")
file_timestamp = "#{basename}.#{ext}"
File.join(output_dir, file_timestamp)
File.join(output_dir, "#{basename}.#{ext}")
end
def schema_to_yml
......@@ -147,7 +146,7 @@ module Pseudonymizer
end
def write_to_csv_file(table, contents)
file_path = output_filename(table, "csv.gz")
file_path = output_filename(table)
Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}."
Zlib::GzipWriter.open(file_path) do |io|
......
......@@ -13,7 +13,7 @@ module Pseudonymizer
end
def upload_dir
File.join(start_at.iso8601)
start_at.iso8601
end
end
end
......@@ -34,7 +34,10 @@ module Pseudonymizer
return unless File.exist?(@output_dir)
progress_output.print "Deleting tmp directory #{@output_dir} ... "
progress_output.puts FileUtils.rm_rf(@output_dir) ? "done".color(:green) : "failed".color(:red)
FileUtils.rm_rf(@output_dir)
progress_output.puts "done".color(:green)
rescue
progress_output.puts "failed".color(:red)
end
private
......
......@@ -23,6 +23,10 @@ describe Pseudonymizer::Uploader do
mock_file("file_list.json")
end
after do
FileUtils.rm_rf(base_dir)
end
describe "#upload" do
it "upload all file in the directory" do
subject.upload
......@@ -38,8 +42,4 @@ describe Pseudonymizer::Uploader do
expect(Dir[File.join(base_dir, "*")].length).to eq(0)
end
end
after do
FileUtils.rm_rf(base_dir)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment