Skip to content

Commit 5b469a5

Browse files
committed
add test for loading IG from directory
1 parent 60d9dbe commit 5b469a5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

spec/extract_tgz_helper.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module ExtractTGZHelper
2+
def extract_tgz(fixture)
3+
filename = File.basename(fixture, '.tgz')
4+
target_dir = Dir.mktmpdir(filename)
5+
system "mkdir -p #{target_dir}"
6+
system "tar -xzf #{fixture} --directory #{target_dir}"
7+
target_dir
8+
end
9+
10+
def cleanup(target_dir)
11+
FileUtils.remove_entry(target_dir)
12+
end
13+
end

spec/inferno/entities/ig_spec.rb

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
require 'extract_tgz_helper'
2+
13
RSpec.describe Inferno::Entities::IG do
4+
include ExtractTGZHelper
5+
26
let(:uscore3_package) { File.expand_path('../../fixtures/uscore311.tgz', __dir__) }
7+
let(:uscore3_untarred) { extract_tgz(uscore3_package) }
8+
9+
after { cleanup(uscore3_untarred) }
310

411
describe '#from_file' do
5-
it 'loads an IG from file' do
12+
it 'loads an IG from tgz file' do
613
ig = described_class.from_file(uscore3_package)
14+
expect_uscore3_loaded_properly(ig)
15+
end
16+
17+
it 'loads an IG from directory' do
18+
ig = described_class.from_file(uscore3_untarred)
19+
expect_uscore3_loaded_properly(ig)
20+
end
721

22+
def expect_uscore3_loaded_properly(ig) # rubocop:disable Naming/MethodParameterName, Metrics/CyclomaticComplexity
823
# For each artifact type in the IG, check:
924
# the right number are loaded,
1025
# they're all the expected type,

0 commit comments

Comments
 (0)