From f96b72cb2052769265eeaa45e5037e7702cfbf1f Mon Sep 17 00:00:00 2001 From: Francisco Rodriguez-Sanchez Date: Tue, 4 Jun 2024 19:34:27 +0200 Subject: [PATCH] improve tests --- tests/testthat/test-cite_packages.R | 17 +++++++++++------ tests/testthat/test-get_pkgs_info.R | 8 +++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-cite_packages.R b/tests/testthat/test-cite_packages.R index b357ff8..29bd6ef 100644 --- a/tests/testthat/test-cite_packages.R +++ b/tests/testthat/test-cite_packages.R @@ -9,24 +9,29 @@ test_that("providing wrong arguments return error", { test_that("cite_packages returns correct citekeys", { expect_identical(cite_packages(output = "citekeys", - pkgs = c("remotes", "renv", "knitr"), + pkgs = c("remotes", "renv", "knitr", "dplyr", + "utils", "tidyverse"), out.dir = tempdir()), - c("knitr2024", "knitr2015", "knitr2014", "remotes", "renv")) + c("knitr2024", "knitr2015", "knitr2014", "remotes", "renv", + "tidyverse", "utils")) }) test_that("cite_packages returns correct table", { tabla <- cite_packages(output = "table", - pkgs = c("remotes", "renv", "knitr"), + pkgs = c("remotes", "renv", "knitr", + "dplyr", "utils", "tidyverse"), out.dir = tempdir()) - expect_true(nrow(tabla) == 3) + expect_true(nrow(tabla) == 5) expect_identical(names(tabla), c("Package", "Version", "Citation")) - expect_identical(tabla$Package, c("knitr", "remotes", "renv")) + expect_identical(tabla$Package, c("knitr", "remotes", "renv", "tidyverse", "utils")) expect_identical(tabla$Citation, list(knitr = "@knitr2014; @knitr2015; @knitr2024", remotes = "@remotes", - renv = "@renv")) + renv = "@renv", + tidyverse = "@tidyverse", + utils = "@utils")) }) diff --git a/tests/testthat/test-get_pkgs_info.R b/tests/testthat/test-get_pkgs_info.R index 082112f..e76e120 100644 --- a/tests/testthat/test-get_pkgs_info.R +++ b/tests/testthat/test-get_pkgs_info.R @@ -1,10 +1,12 @@ test_that("get_pkgs_info works", { - info <- get_pkgs_info(pkgs = c("renv", "remotes", "dplyr", "ggplot2", "knitr"), + info <- get_pkgs_info(pkgs = c("renv", "remotes", "dplyr", "ggplot2", "knitr", + "utils"), out.dir = tempdir()) - expect_identical(info$pkg, c("knitr", "remotes", "renv", "tidyverse")) + expect_identical(info$pkg, c("knitr", "remotes", "renv", "tidyverse", "utils")) expect_identical(info$citekeys, list(knitr = c("knitr2024", "knitr2015", "knitr2014"), remotes = "remotes", renv = "renv", - tidyverse = "tidyverse")) + tidyverse = "tidyverse", + utils = "utils")) })