Skip to content

Commit

Permalink
Improved various tests.
Browse files Browse the repository at this point in the history
- Added extra test for excluding ..* in listings.
- Fixed tests for uploading directly from the staging directory.
  • Loading branch information
LTLA committed Apr 23, 2024
1 parent ea1b0bc commit b7ae1f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tests/testthat/test-list.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ test_that("listFiles works as expected", {
rfiles <- sort(listFiles("test", "list", "v1", registry=info$registry, url=info$url, forceRemote=TRUE))
expect_identical(files, rfiles)

files <- sort(listFiles("test", "list", "v1", registry=info$registry, url=info$url, include..=FALSE))
expect_identical(files, sort(c("foo", "whee/blah", "whee2")))
rfiles <- sort(listFiles("test", "list", "v1", registry=info$registry, url=info$url, include..=FALSE, forceRemote=TRUE))
expect_identical(files, rfiles)

files <- sort(listFiles("test", "list", "v1", registry=info$registry, url=info$url, prefix="whee"))
expect_identical(files, sort(c("whee/blah", "whee2")))
rfiles <- sort(listFiles("test", "list", "v1", registry=info$registry, url=info$url, forceRemote=TRUE, prefix="whee"))
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ test_that("upload works as expected for links", {
expect_null(man[["whee"]]$link)
})

test_that("upload works as expected for new versions", {
test_that("upload works directly from the staging directory", {
dir <- allocateUploadDirectory(info$staging)
write(file=file.path(dir, "blah.txt"), LETTERS)
write(file=file.path(dir, "blah.txt"), letters)
dir.create(file.path(dir, "foo"))
write(file=file.path(dir, "foo", "bar.txt"), 1:10)

Expand All @@ -81,6 +81,8 @@ test_that("upload works as expected for new versions", {
url=info$url
)

man <- fetchManifest("test-upload", "jennifer", "1", registry=info$registry)
man <- fetchManifest("test-upload", "jennifer", "3", registry=info$registry)
expect_identical(sort(names(man)), c("blah.txt", "foo/bar.txt"))
expect_null(man[["blah.txt"]]$link)
expect_false(is.null(man[["foo/bar.txt"]]$link))
})

0 comments on commit b7ae1f5

Please sign in to comment.