Skip to content

Commit

Permalink
tested start_qsub, start_rabbitmq, start_serial
Browse files Browse the repository at this point in the history
  • Loading branch information
meetagrawal09 committed Jul 2, 2023
1 parent 27e9122 commit 99771a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions base/remote/tests/testthat/test.start_qsub.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("`start_qsub()` able to correctly make the command to be executed remotely to start qsub runs", {
mocked_res <- mockery::mock(0)
mockery::stub(start_qsub, 'remote.execute.cmd', mocked_res)
res <- start_qsub(1, "qsub -N @NAME@ -o @STDOUT@ -e @STDERR@", "test_rundir", "pecan", "test_host_rundir", "test_host_outdir", "test_stdout_log", "test_stderr_log", "test_job_script")
args <- mockery::mock_args(mocked_res)
expect_equal(args[[1]][[1]], 'pecan')
expect_equal(args[[1]][[2]], c('qsub', '-N', 'PEcAn-1', '-o', 'test_host_outdir/1/test_stdout_log', '-e', 'test_host_outdir/1/test_stderr_log'))
expect_equal(args[[1]][[3]][[1]], 'test_host_rundir/1/test_job_script')
expect_equal(args[[1]]$stderr, TRUE)
expect_equal(res, 0)
})
13 changes: 13 additions & 0 deletions base/remote/tests/testthat/test.start_rabbitmq.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test_that("`start_rabbitmq()` able to correctly read the environment varibles and send desired values to rabbitmq_post_message", {
withr::with_envvar(c("RABBITMQ_PREFIX" = "prefix", "RABBITMQ_PORT" = "3000"),{
mocked_res <- mockery::mock(TRUE)
mockery::stub(start_rabbitmq, 'rabbitmq_post_message', mocked_res)
res <- start_rabbitmq('test_folder', 'test_uri', 'test_queue')
args <- mockery::mock_args(mocked_res)
expect_equal(args[[1]][[1]], 'test_uri')
expect_equal(args[[1]][[2]], 'test_queue')
expect_equal(args[[1]][[3]], list(folder = 'test_folder'))
expect_equal(args[[1]][[4]], 'prefix')
expect_equal(args[[1]][[5]], '3000')
})
})
9 changes: 9 additions & 0 deletions base/remote/tests/testthat/test.start_serial.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test_that("`start_serial()` able to pass desired parameters to execute command remotely to start model execution in serial mode",{
mocked_res <- mockery::mock(TRUE)
mockery::stub(start_serial, 'remote.execute.cmd', mocked_res)
res <- start_serial('test_run', 'pecan', 'test_rundir', 'test_host_rundir', 'test_job_script')
args <- mockery::mock_args(mocked_res)
expect_equal(args[[1]][[1]], 'pecan')
expect_equal(args[[1]][[2]], 'test_host_rundir/test_run/test_job_script')
expect_equal(res, TRUE)
})

0 comments on commit 99771a9

Please sign in to comment.