Skip to content

Commit

Permalink
Bunch of test fixes for fetching.
Browse files Browse the repository at this point in the history
- fixed tests for remote directory fetching.
- hardened tests for missing latest versions.
  • Loading branch information
LTLA committed Apr 22, 2024
1 parent 30d6b0b commit 3d043ad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/testthat/test-fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ test_that("fetchSummary works as expected", {

test_that("fetchLatest works as expected", {
expect_identical(fetchLatest("test", "fetch", registry=info$registry, url=info$url), "v2")
expect_null(fetchLatest("test", "missing", registry=info$registry, url=info$url))

expect_identical(fetchLatest("test", "fetch", registry=info$registry, url=info$url, forceRemote=TRUE), "v2")
expect_null(fetchLatest("test", "missing", registry=info$registry, url=info$url, forceRemote=TRUE))
})

test_that("fetchUsage works as expected", {
Expand Down Expand Up @@ -66,14 +69,14 @@ test_that("fetchDirectory works as expected", {
write(file=file.path(rdir, "foo"), "more-bar")
rdir2 <- fetchDirectory("test/fetch/v2", registry=info$registry, url=info$url, cache=cache, forceRemote=TRUE)
expect_identical(rdir, rdir2)
expect_identical(readLines(file.path(rdir, "foo")), "more-bar")
expect_identical(readLines(file.path(rdir2, "foo")), "more-bar")

# Unless we force an overwrite.
rdir2 <- fetchDirectory("test/fetch/v2", registry=info$registry, url=info$url, cache=cache, forceRemote=TRUE, overwrite=TRUE)
expect_identical(readLines(file.path(rdir, "foo")), "BAR")
expect_identical(readLines(file.path(rdir2, "foo")), "BAR")

# Trying with multiple cores.
cache <- tempfile()
rdir2 <- fetchDirectory("test/fetch/v2", registry=info$registry, url=info$url, cache=cache, forceRemote=TRUE, concurrent=2)
expect_identical(readLines(file.path(rdir, "foo")), "BAR")
expect_identical(readLines(file.path(rdir2, "foo")), "BAR")
})

0 comments on commit 3d043ad

Please sign in to comment.