Skip to content

Commit

Permalink
correct sequence of tests and reset clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
rfhb committed Aug 6, 2023
1 parent fc5cee3 commit 33db78d
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions inst/tinytest/more_test_ctrdata_param_checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if (!checkSqlite()) exit_file("Reason: no SQLite")
## test function
tf <- function() {

if (Sys.info()[["sysname"]] != "Linux") {
clipr::clear_clip()
}

## database in memory
dbc <- nodbi::src_sqlite(
collection = "inmemory"
Expand Down Expand Up @@ -324,6 +328,29 @@ tf <- function() {
url = qt[[1]]))[[1]] == qt[[2]]},
logical(1L))))

#### clipboard ####
if (Sys.info()[["sysname"]] != "Linux") {

clipr::clear_clip()
clipr::write_clip(
queryurls[[1]][1],
allow_non_interactive = TRUE)
expect_message(
tmp <- ctrGetQueryUrl(),
"Found search query")
expect_true(is.data.frame(tmp))
expect_equal(tmp[["query-term"]], queryurls[[1]][2])
rm(tmp)

clipr::write_clip(
"NotARegisterUrl",
allow_non_interactive = TRUE)
expect_error(
ctrGetQueryUrl(),
"no clinical trial register")

}

# URLs for single studies
queryurls <- list(
# euctr
Expand Down Expand Up @@ -353,28 +380,6 @@ tf <- function() {
url = qt[[1]]))[[1]] == qt[[2]]},
logical(1L))))

#### clipboard ####
if (Sys.info()[["sysname"]] != "Linux") {

clipr::write_clip(
queryurls[[1]][1],
allow_non_interactive = TRUE)
expect_message(
tmp <- ctrGetQueryUrl(),
"Found search query")
expect_true(is.data.frame(tmp))
expect_equal(tmp[["query-term"]], queryurls[[1]][2])
rm(tmp)

clipr::write_clip(
"NotARegisterUrl",
allow_non_interactive = TRUE)
expect_error(
ctrGetQueryUrl(),
"no clinical trial register")

}

# clean up
rm(queryurls)

Expand Down

0 comments on commit 33db78d

Please sign in to comment.