Skip to content

Commit

Permalink
Add test, make test silent
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed May 10, 2024
1 parent e5c9c89 commit 9e8d9d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CRAN_PACKAGE_DB <- kwb.package:::getCranPackageDatabase()
2 changes: 1 addition & 1 deletion tests/testthat/test-function-downloadGitHubPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("downloadGitHubPackage() works", {

expect_error(f())

result <- f("kwb-r/kwb.utils")
suppressMessages(result <- f("kwb-r/kwb.utils"))

expect_true(endsWith(result, ".tar.gz"))
expect_true(file.exists(result))
Expand Down
21 changes: 11 additions & 10 deletions tests/testthat/test-function-getPackageLicences.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#
# This file was generated by kwb.test::create_test_files(),
# launched by hsonne on 2024-05-02 17:58:28.
# Please modify the dummy functions so that real cases are
# tested. Then, delete this comment.
#
#library(testthat)
#source("tests/testthat/setup.R")

test_that("getPackageLicences() works", {

f <- kwb.package::getPackageLicences

expect_error(
f()
# Argument "packages" fehlt (ohne Standardwert)
)
expect_error(f())

# CRAN_PACKAGE_DB is loaded in testthat/setup.R
result <- f("kwb.utils", db = CRAN_PACKAGE_DB)

expect_true(nrow(result) == 1L)
expect_true(all(is.na(kwb.utils::removeColumns(result, c("package", "licence")))))
expect_identical(result$licence, "<not_found>")

expect_identical(f("dplyr")$package, "dplyr")
})

0 comments on commit 9e8d9d6

Please sign in to comment.