Skip to content

Commit

Permalink
FI-3440: Add IG spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dehall committed Dec 12, 2024
1 parent 1b1ab63 commit b59422a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Binary file added spec/fixtures/uscore311.tgz
Binary file not shown.
39 changes: 39 additions & 0 deletions spec/inferno/dsl/ig_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
RSpec.describe Inferno::DSL::IG do
let(:uscore3_package) { File.expand_path('../../fixtures/uscore311.tgz', __dir__) }

describe '#from_file' do
it 'loads an IG from file' do
ig = described_class.from_file(uscore3_package)

# For each artifact type in the IG, check:
# the right number are loaded,
# they're all the expected type,
# and spot check a couple IDs

# https://www.hl7.org/fhir/us/core/STU3.1.1/profiles.html
expect(ig.profiles.length).to eq(26)
expect(ig.profiles.map(&:resourceType).uniq).to eq(['StructureDefinition'])
expect(ig.profiles.map(&:id)).to include('us-core-patient', 'us-core-condition',
'head-occipital-frontal-circumference-percentile')

expect(ig.extensions.length).to eq(4)
expect(ig.extensions.map(&:resourceType).uniq).to eq(['StructureDefinition'])
expect(ig.extensions.map(&:type).uniq).to eq(['Extension'])
expect(ig.extensions.map(&:id)).to include('us-core-race', 'us-core-ethnicity')

# https://www.hl7.org/fhir/us/core/STU3.1.1/terminology.html
expect(ig.value_sets.length).to eq(32)
expect(ig.value_sets.map(&:resourceType).uniq).to eq(['ValueSet'])
expect(ig.value_sets.map(&:id)).to include('us-core-usps-state', 'simple-language')

# https://www.hl7.org/fhir/us/core/STU3.1.1/searchparameters.html
expect(ig.search_params.length).to eq(74)
expect(ig.search_params.map(&:resourceType).uniq).to eq(['SearchParameter'])
expect(ig.search_params.map(&:id)).to include('us-core-patient-name', 'us-core-encounter-id')

# https://www.hl7.org/fhir/us/core/STU3.1.1/all-examples.html
expect(ig.examples.length).to eq(84)
expect(ig.examples.map(&:id)).to include('child-example', 'self-tylenol')
end
end
end
10 changes: 10 additions & 0 deletions spec/inferno/utils/ig_downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ def with_temp_path(name)
expect(File.read(temp_path)).to eq(package_binary)
end
end

it 'successfully downloads package to custom path' do
stub_request(:get, 'https://packages.fhir.org/hl7.fhir.us.udap-security/-/hl7.fhir.us.udap-security-1.0.0.tgz')
.to_return(body: package_binary)

with_temp_path('ig-downloader-canonical') do |temp_path|
ig_downloader.load_ig(canonical, nil, { verbose: false }, temp_path)
expect(File.read(temp_path)).to eq(package_binary)
end
end
end
end

Expand Down

0 comments on commit b59422a

Please sign in to comment.