Skip to content

Commit

Permalink
Merge pull request #266 from vimc/vimc-4574
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz authored Feb 11, 2021
2 parents f8845b2 + dcbe619 commit f0fd3a6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: orderly
Title: Lightweight Reproducible Reporting
Version: 1.2.23
Version: 1.2.24
Description: Order, create and store reports from R. By defining a
lightweight interface around the inputs and outputs of an
analysis, a lot of the repetitive work for reproducible research
Expand Down Expand Up @@ -31,6 +31,7 @@ Imports:
digest,
docopt,
fs (>= 1.2.7),
gert,
ids,
withr,
yaml,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# orderly 1.2.24

* `orderly_run_remote` checks that ref exists before running (VIMC-4574)

# orderly 1.2.23

* `orderly_run` with non-boolean `use_draft` and fixed ID dependency works (#259)
Expand Down
6 changes: 5 additions & 1 deletion R/remote.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ orderly_run_remote <- function(name, parameters = NULL, ref = NULL,
progress = TRUE,
root = NULL, locate = TRUE, instance = NULL,
remote = NULL) {
remote <- get_remote(remote, orderly_config(root, locate))
cfg <- orderly_config(root, locate)
if (!is.null(ref)) {
ref <- gert::git_commit_id(ref, cfg$root)
}
remote <- get_remote(remote, cfg)
invisible(remote$run(
name, parameters = parameters, ref = ref,
timeout = timeout, wait = wait, poll = poll,
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RUN install2.r \
digest \
docopt \
fs \
gert \
ids \
jsonlite \
knitr \
Expand Down
34 changes: 34 additions & 0 deletions tests/testthat/test-remote.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,37 @@ test_that("orderly_bundle_(pack|import)_remote do not use root/locate", {

expect_equal(remote$list_versions("example"), ans$id)
})


test_that("orderly run remote passes ref to run", {
path <- prepare_orderly_git_example()

## Create a minimal remote class which will satisfy implements_remote
mock_remote <- R6::R6Class(
"orderly_mock_remote",
lock_objects = FALSE,
public = list(
list_reports = function() TRUE,
list_versions = function() TRUE,
pull = function() TRUE,
url_report = function() TRUE
)
)

## Bit of awkwardness with adding run function here. We want to mock out new
## function but can't do that inside the class.
remote <- mock_remote$new()
remote$run <- mockery::mock(TRUE, cycle = TRUE)
orderly_run_remote("minimal", remote = remote, root = path[["local"]])

mockery::expect_called(remote$run, 1)
args <- mockery::mock_args(remote$run)[[1]]
expect_null(args$ref)

orderly_run_remote("minimal", remote = remote, root = path[["local"]],
ref = "master")

mockery::expect_called(remote$run, 2)
args <- mockery::mock_args(remote$run)[[2]]
expect_match(args$ref, "[0-9a-f]{40}")
})

0 comments on commit f0fd3a6

Please sign in to comment.