Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Feb 28, 2024
1 parent 4caad52 commit 3a8eeaa
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tests/test-assert_package.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
expect_error <- function(x, e = "") {
invisible(grepl(e, tryCatch(x, error = identity)[["message"]], fixed = TRUE) || stop("Error '", e, "' not generated"))
invisible(
grepl(e, tryCatch(x, error = identity)[["message"]], fixed = TRUE) ||
stop("Error '", e, "' not generated")
)
}

expect_error(r.releases.utils::assert_package(path = c(1L, 2L)), "Invalid package file path")
expect_error(r.releases.utils::assert_package(path = tempfile()), "does not exist")
expect_error(
r.releases.utils::assert_package(path = c(1L, 2L)),
"Invalid package file path"
)

expect_error(
r.releases.utils::assert_package(path = tempfile()),
"does not exist"
)

path <- file.path(tempfile(), "hy-phens")
dir.create(dirname(path))
file.create(path)
expect_error(r.releases.utils::assert_package(path = path), "invalid package name")
expect_error(
r.releases.utils::assert_package(path = path),
"invalid package name"
)
unlink(dirname(path), recursive = TRUE)

path <- file.path(tempfile(), "package")
dir.create(dirname(path))
writeLines(letters, path)
expect_error(r.releases.utils::assert_package(path = path), "Invalid package URL")
expect_error(
r.releases.utils::assert_package(path = path),
"Invalid package URL"
)
unlink(dirname(path), recursive = TRUE)

path <- file.path(tempfile(), "package")
dir.create(dirname(path))
writeLines("b a d", path)
expect_error(r.releases.utils::assert_package(path = path), "Found malformed URL")
expect_error(
r.releases.utils::assert_package(path = path),
"Found malformed URL"
)
unlink(dirname(path), recursive = TRUE)

path <- file.path(tempfile(), "package")
Expand Down

0 comments on commit 3a8eeaa

Please sign in to comment.