Skip to content

Commit

Permalink
refactor another test case
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Jul 15, 2024
1 parent b276bcd commit 2be09b6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions ood_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "timecop", "~> 0.8"
spec.add_development_dependency "climate_control", "~> 1.2.0"
spec.add_development_dependency "minitest", "~> 5"
spec.add_development_dependency "mocha", "~> 2.4"
end
7 changes: 7 additions & 0 deletions test/job/adapters/slurm_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ def test_submit_interface
veryify_keywords(slurm, :submit, [:after, :afterok, :afternotok, :afterany])
verify_args(slurm, :submit, 1)
end

def test_submitting_with_hold
slurm = slurm_instance
stub_submit
OodCore::Job::Adapters::Slurm::Batch.any_instance.expects(:submit_string).with(script_content, args: ["-H", "--export", "NONE"], env: {})
slurm.submit(build_script(submit_as_hold: true))
end
end
23 changes: 22 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'ood_core'
require 'mocha/minitest'

module TestHelper

Expand All @@ -25,4 +26,24 @@ def verify_args(object, method, num_of_args)

assert_equal(actual_num_of_args, num_of_args)
end
end

def build_script(opts = {})
OodCore::Job::Script.new(
**{
content: script_content
}.merge(opts)
)
end

def script_content
"my job script"
end

def stub_submit(jobid = '123')
Open3.stubs(:capture3).returns([jobid, '', exit_success])
end

def exit_success
OpenStruct.new(:success? => true, :exitstatus => 0)
end
end

0 comments on commit 2be09b6

Please sign in to comment.