Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakillo committed Jun 4, 2024
1 parent 64d2df7 commit f96b72c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 11 additions & 6 deletions tests/testthat/test-cite_packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

})

Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-get_pkgs_info.R
Original file line number Diff line number Diff line change
@@ -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"))
})

0 comments on commit f96b72c

Please sign in to comment.