Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename as arguments of driver.rb #16

Merged
merged 1 commit into from
Jul 7, 2022
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
11 changes: 6 additions & 5 deletions lib/TestScriptEngine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative './TestScriptRunnable'

class TestScriptEngine
attr_accessor :endpoint, :directory_path
attr_accessor :endpoint, :directory_path, :file_name

def scripts
@scripts ||= {}
Expand All @@ -25,9 +25,10 @@ def client
@client ||= FHIR::Client.new(endpoint || 'localhost:3000')
end

def initialize(endpoint = nil, directory_path = nil)
def initialize(endpoint = nil, directory_path = nil, file_name = nil)
self.endpoint = endpoint
self.directory_path = directory_path
self.file_name = file_name
end

# TODO: Tie-in stronger validation. Possibly, Inferno validator.
Expand All @@ -37,9 +38,9 @@ def valid_testscript? script

# @path [String] Optional, specifies the path to the folder containing the
# TestScript Resources to-be loaded into the engine.
def load_scripts path = nil, file_name = nil
on_deck = Dir.glob "#{path || root}/**/*.{json, xml}"
FHIR.logger.info "[.load_scripts] TestScript Path: [#{path || root}]"
def load_scripts
on_deck = Dir.glob "#{root}/**/*.{json, xml}"
FHIR.logger.info "[.load_scripts] TestScript Path: [#{root}]"

on_deck.each do |resource|
next if file_name && !resource.include?(file_name)
Expand Down
13 changes: 7 additions & 6 deletions lib/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
require './TestScriptRunnable' # TODO: Remove

test_server_url = 'http:https://hapi.fhir.org/baseR4'
testscript_path = nil
testscript_path = '../TestScripts'
testscript_file = nil

parameters = ARGV
parameters.each do |parameter|
if parameter.start_with?('http')
test_server_url = parameter
elsif parameter.include?('.json')
testscript_file = parameter
else
testscript_path = parameter
end
end

puts "SERVER: #{test_server_url}"
puts "TESTSCRIPTS: #{testscript_path}"
puts "TESTSCRIPT PATH: #{testscript_path}"
puts "TESTSCRIPT FILE: #{testscript_file}"

default_engine = TestScriptEngine.new(test_server_url, testscript_path)
# Load and execute all TestScript in /TestScripts
default_engine = TestScriptEngine.new(test_server_url, testscript_path, testscript_file)
default_engine.load_scripts
# Specify a TestScript to execute
# default_engine.load_scripts(nil, 'general_test_script.json')
default_engine.make_runnables
default_engine.execute_runnables
default_engine.write_reports
Expand Down