Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-24.04

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true

- name: Run unit tests
run: bundle exec rake test_unit
4 changes: 3 additions & 1 deletion lib/resource_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.set_fields!(resource, namespace, embedded=0)
# definition in the DSTU2 models. So here, we're just skipping Quantity choice,
# and selecting some other (probably primitive) type for the multi-choice FHIR property.
ignore_multiple_types = ['Meta']
ignore_multiple_types += 'Quantity' if namespace == 'FHIR::DSTU2'
ignore_multiple_types += ['Quantity'] if namespace == 'FHIR::DSTU2'
selected_multiples = multiples.map { |k| "#{k}#{resource.class::MULTIPLE_TYPES[k].reject { |t| ignore_multiple_types.include?(t) }.sample.titleize.split.join}" }
unselected_multiples = all_multiples - selected_multiples
end
Expand Down Expand Up @@ -121,6 +121,8 @@ def self.set_fields!(resource, namespace, embedded=0)
c.system = 'https://www.usps.com/'
c.code = ['CA','TX','NY','MA','DC'].sample
end
elsif type == 'CodeableConcept' && meta['binding'] && meta['binding']['strength'] == 'required' && !meta['valid_codes'] && meta['min'] == 0
gen = nil # Cannot generate valid code for external required binding (e.g. LOINC/SNOMED); field is optional so safe to skip
elsif type == 'Coding' && meta['valid_codes'] && meta['binding']
gen.system = meta['valid_codes'].keys.sample
gen.code = meta['valid_codes'][gen.system].sample
Expand Down
4 changes: 2 additions & 2 deletions lib/tests/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def initialize(client, client2=nil)
end

def version_namespace
if @client.fhir_version.to_s.upcase == 'DSTU2'
if @client&.fhir_version.to_s.upcase == 'DSTU2'
"FHIR::DSTU2".constantize
elsif @client.fhir_version.to_s.upcase == 'STU3'
elsif @client&.fhir_version.to_s.upcase == 'STU3'
"FHIR::STU3".constantize
else
"FHIR".constantize
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/testscripts/testscript_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(client=nil, client2=nil)
@client = client
@client2 = client2
@scripts = []
load_testscripts if client.fhir_version != :dstu2 # Run tests scripts on STU3+ only.
load_testscripts if client&.fhir_version != :dstu2 # Run tests scripts on STU3+ only.
end

def tests
Expand Down
2 changes: 1 addition & 1 deletion test/unit/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_testscript_find

testscript_engine = Crucible::Tests::TestScriptEngine.new(nil)

keyed_test = testscript_engine.find_test('TS-testscript-example')
keyed_test = testscript_engine.find_test(tests.keys.first)
assert !keyed_test.nil?, "Failed to find testscript by key"
end

Expand Down
Loading