Skip to content

Commit

Permalink
Removed tmp directory logic for sqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanAkbar authored and ronaldtse committed Mar 9, 2024
1 parent 98e217e commit 3290a4a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions spec/acceptance/xlsx2db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,39 @@

RSpec.describe "IEV" do
let(:sample_xlsx_file) { fixture_path("sample-file.xlsx") }
let(:tmp_db_dir) { "tmp-db-dir" }

describe "xlsx2db" do
it "imports XLSX document to database" do
Dir.mktmpdir("iev-test") do |dir|
dbfile = "#{dir}/test.sqlite3"
command = %W(xlsx2db #{sample_xlsx_file} -o #{dbfile})
silence_output_streams { IEV::CLI.start(command) }
FileUtils.rm_rf(tmp_db_dir) if Dir.exist?(tmp_db_dir)

expect(dbfile).to satisfy { |p| File.file? p }
Dir.mkdir tmp_db_dir

db = SQLite3::Database.new(dbfile)
dbfile = File.join(tmp_db_dir, "test.sqlite3")
command = %W(xlsx2db #{sample_xlsx_file} -o #{dbfile})
silence_output_streams { IEV::CLI.start(command) }

sql = <<~SQL
select count(*)
from concepts
where language = 'en'
SQL
expect(dbfile).to satisfy { |p| File.file? p }

expect(db.execute(sql).first.first).to eq(2)
db = SQLite3::Database.new(dbfile)

sql = <<~SQL
select term
from concepts
where language = 'en' and ievref = '103-01-01'
SQL
sql = <<~SQL
select count(*)
from concepts
where language = 'en'
SQL

expect(db.execute(sql).first.first).to eq("function")
expect(db.execute(sql).first.first).to eq(2)

FileUtils.rm_rf Dir.glob(File.join(dir, "*"))
end
sql = <<~SQL
select term
from concepts
where language = 'en' and ievref = '103-01-01'
SQL

expect(db.execute(sql).first.first).to eq("function")

FileUtils.rm_rf(tmp_db_dir)
end
end
end

0 comments on commit 3290a4a

Please sign in to comment.