diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..cd3f785 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1 @@ +CRAN_PACKAGE_DB <- kwb.package:::getCranPackageDatabase() diff --git a/tests/testthat/test-function-downloadGitHubPackage.R b/tests/testthat/test-function-downloadGitHubPackage.R index e7a117b..ae5a0ba 100644 --- a/tests/testthat/test-function-downloadGitHubPackage.R +++ b/tests/testthat/test-function-downloadGitHubPackage.R @@ -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)) diff --git a/tests/testthat/test-function-getPackageLicences.R b/tests/testthat/test-function-getPackageLicences.R index 33933f3..502800e 100644 --- a/tests/testthat/test-function-getPackageLicences.R +++ b/tests/testthat/test-function-getPackageLicences.R @@ -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, "") + + expect_identical(f("dplyr")$package, "dplyr") })