Skip to content

Commit

Permalink
refactor tests with expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdaradunGaztea committed Apr 14, 2024
1 parent b1c78f0 commit 0017b31
Show file tree
Hide file tree
Showing 30 changed files with 257 additions and 119 deletions.
276 changes: 207 additions & 69 deletions tests/testthat/setup-test_params.R

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/testthat/test-bioc-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("a", {
# TESTS ----
test_dependencies(Biostrings_deps)
test_cache({ wood_bioc_dependencies("Biostrings") }, Biostrings_deps)
test_param_package(wood_bioc_dependencies)
test_param_bioc_release(wood_bioc_dependencies, package = "Biostrings")
test_param_package(wood_bioc_dependencies(package = "Biostrings"))
test_param_bioc_release(wood_bioc_dependencies(package = "Biostrings"))

test_that("raises an exception if package not available", {
expect_error(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-bioc-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("c", {
# TESTS ----
test_packages(bioc_packages)
test_cache({ wood_bioc_packages() }, bioc_packages)
test_param_bioc_release(wood_bioc_packages)
test_param_bioc_release(wood_bioc_packages())

test_that("there's a Biostrings package in the list", {
expect_subset("Biostrings", bioc_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-bioc-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("f", {
# TESTS ----
test_version(affy_version)
test_cache({ wood_bioc_version("affy") }, affy_version)
test_param_package(wood_bioc_version)
test_param_bioc_release(wood_bioc_version, package = "affy")
test_param_package(wood_bioc_version(package = "affy"))
test_param_bioc_release(wood_bioc_version(package = "affy"))

with_mock_dir("g", {
test_that("correctly retrieves data from older releases", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-core-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ stats_deps <- wood_core_dependencies("stats")

# TESTS ----
test_dependencies(stats_deps)
test_param_package(wood_core_dependencies)
test_param_package(wood_core_dependencies(package = "stats"))

test_that("raises an exception if package not available", {
expect_error(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-core-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ utils_version <- wood_core_version("utils")

# TESTS ----
test_version(utils_version)
test_param_package(wood_core_version)
test_param_package(wood_core_version(package = "utils"))

test_that("raises an exception if package not available", {
expect_error(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-cran-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("h", {
# TESTS ----
test_dependencies(deepdep_deps)
test_cache({ wood_cran_dependencies("deepdep", version = "0.2.0") }, deepdep_deps)
test_param_package(wood_cran_dependencies, version = "0.2.0")
test_param_version(wood_cran_dependencies, package = "deepdep")
test_param_package(wood_cran_dependencies(package = "deepdep", version = "0.2.0"))
test_param_version(wood_cran_dependencies(package = "deepdep", version = "0.2.0"))

test_that("uses cache from wood_cran_versions() if available", {
wood_clear_cache()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-cran-latest.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("j", {
# TESTS ----
test_version(versionsort_latest)
test_cache({ wood_cran_latest("versionsort") }, versionsort_latest)
test_param_package(wood_cran_latest)
test_param_package(wood_cran_latest(package = "versionsort"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-cran-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("l", {
# TESTS ----
test_versions(versionsort_versions)
test_cache({ wood_cran_versions("versionsort") }, versionsort_versions)
test_param_package(wood_cran_versions)
test_param_package(wood_cran_versions(package = "versionsort"))

test_that("versionsort versions contain some of the published version codes", {
expect_subset(c("1.0.0", "1.1.0"), versionsort_versions)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-deps-filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ empty_deps <- as_wood_deps(data.frame(

# TESTS ----
test_dependencies(filter_dependencies(woodendesc_deps, "strong"))
test_param_which_deps(filter_dependencies, object = empty_deps)
test_param_which_deps(filter_dependencies(object = empty_deps))
lapply(filter_dependencies(mixed_deps, "strong"), function(deps) {
test_dependencies(deps)
})
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-github-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ with_mock_dir("n", {
# TESTS ----
test_dependencies(gglgbtq_deps)
test_cache({ wood_github_dependencies("gglgbtq", "turtletopia", tag = "v0.1.0") }, gglgbtq_deps)
test_param_package(wood_github_dependencies, user = "turtletopia")
test_param_gh_user(wood_github_dependencies, package = "gglgbtq")
test_param_tag(wood_github_dependencies, package = "gglgbtq", user = "turtletopia")
test_param_package(wood_github_dependencies(package = "gglgbtq", user = "turtletopia"))
test_param_gh_user(wood_github_dependencies(package = "gglgbtq", user = "turtletopia"))
test_param_tag(wood_github_dependencies(package = "gglgbtq", user = "turtletopia"))

with_mock_dir("o", {
test_that("uses cache from wood_github_versions() if available if not latest commit", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-github-latest.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ with_mock_dir("q", {
# TESTS ----
test_version(gglgbtq_latest)
test_cache({ wood_github_latest("gglgbtq", "turtletopia") }, gglgbtq_latest)
test_param_package(wood_github_latest, user = "turtletopia")
test_param_gh_user(wood_github_latest, package = "gglgbtq")
test_param_package(wood_github_latest(package = "gglgbtq", user = "turtletopia"))
test_param_gh_user(wood_github_latest(package = "gglgbtq", user = "turtletopia"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-github-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ turtletopia_packages <- wood_github_packages("turtletopia")
# TESTS ----
test_packages(turtletopia_packages)
test_cache({ wood_github_packages(user = "turtletopia") }, turtletopia_packages)
test_param_gh_user(wood_github_packages)
test_param_include_forks(wood_github_packages, user = "turtletopia")
test_param_gh_user(wood_github_packages(user = "turtletopia"))
test_param_include_forks(wood_github_packages(user = "turtletopia"))

test_that("several packages make the list", {
expect_subset(c("versionsort", "gglgbtq", "woodendesc"), turtletopia_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-github-tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ with_mock_dir("s", {
# TESTS ----
test_tags(gglgbtq_tags)
test_cache({ wood_github_tags("gglgbtq", "turtletopia") }, gglgbtq_tags)
test_param_package(wood_github_tags, user = "turtletopia")
test_param_gh_user(wood_github_tags, package = "gglgbtq")
test_param_package(wood_github_tags(package = "gglgbtq", user = "turtletopia"))
test_param_gh_user(wood_github_tags(package = "gglgbtq", user = "turtletopia"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-github-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ with_mock_dir("t", {
# TESTS ----
test_versions(gglgbtq_versions)
test_cache({ wood_github_versions("gglgbtq", "turtletopia") }, gglgbtq_versions)
test_param_package(wood_github_versions, user = "turtletopia")
test_param_gh_user(wood_github_versions, package = "gglgbtq")
test_param_package(wood_github_versions(package = "gglgbtq", user = "turtletopia"))
test_param_gh_user(wood_github_versions(package = "gglgbtq", user = "turtletopia"))

test_that("gglgbtq versions contain some of the tagged version codes", {
expect_subset(c("0.1.0", "0.1.1"), gglgbtq_versions)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-gitlab-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ with_mock_dir("l0", {
# TESTS ----
test_dependencies(rock_deps)
test_cache({ wood_gitlab_dependencies("rock", "r-packages", tag = "0.6.0") }, rock_deps)
test_param_package(wood_gitlab_dependencies, user = "r-packages")
test_param_gh_user(wood_gitlab_dependencies, package = "rock")
test_param_tag(wood_gitlab_dependencies, package = "rock", user = "r-packages")
test_param_package(wood_gitlab_dependencies(package = "rock", user = "r-packages"))
test_param_gh_user(wood_gitlab_dependencies(package = "rock", user = "r-packages"))
test_param_tag(wood_gitlab_dependencies(package = "rock", user = "r-packages"))

# with_mock_dir("l1", {
# test_that("uses cache from wood_gitlab_versions() if available if not latest commit", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-gitlab-latest.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("l3", {
# TESTS ----
test_version(rock_latest)
test_cache({ wood_gitlab_latest("rock", "r-packages") }, rock_latest)
test_param_package(wood_gitlab_latest, user = "r-packages")
test_param_gh_user(wood_gitlab_latest, package = "rock")
test_param_package(wood_gitlab_latest(package = "rock", user = "r-packages"))
test_param_gh_user(wood_gitlab_latest(package = "rock", user = "r-packages"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-gitlab-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("l4", {
# TESTS ----
test_packages(r_packages_packages)
test_cache({ wood_gitlab_packages(user = "r-packages") }, r_packages_packages)
test_param_gh_user(wood_gitlab_packages)
test_param_include_forks(wood_gitlab_packages, user = "r-packages")
test_param_gh_user(wood_gitlab_packages(user = "r-packages"))
test_param_include_forks(wood_gitlab_packages(user = "r-packages"))

test_that("several packages make the list", {
expect_subset(c("rock", "limonaid", "preregr"), r_packages_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-local-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ woodendesc_deps <- wood_local_dependencies("woodendesc")

# TESTS ----
test_dependencies(woodendesc_deps)
test_param_package(wood_local_dependencies)
test_param_paths(wood_local_dependencies, package = "woodendesc")
test_param_package(wood_local_dependencies(package = "woodendesc"))
test_param_paths(wood_local_dependencies(package = "woodendesc"))

test_that("raises an exception if package not available", {
expect_error(wood_local_dependencies("fakepackage"))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-local-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local_packages <- wood_local_packages()

# TESTS ----
test_packages(local_packages)
test_param_paths(wood_local_packages)
test_param_paths(wood_local_packages())

test_that("local packages include woodendesc package", {
expect_subset("woodendesc", local_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-local-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ lib_dir <- local_fake_library("fakepackage", "woodendesc")
lib_dir_2 <- local_fake_library("fakepackage", "woodendesc", path = "fake_dir")

# TESTS ----
test_param_package(wood_local_versions)
test_param_paths(wood_local_versions, package = "woodendesc")
test_param_package(wood_local_versions(package = "woodendesc"))
test_param_paths(wood_local_versions(package = "woodendesc"))

woodendesc_versions <- wood_local_versions("woodendesc")

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-runiverse-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("u", {
# TESTS ----
test_dependencies(ggplot2_deps)
test_cache({ wood_runiverse_dependencies("ggplot2", "tidyverse") }, ggplot2_deps)
test_param_package(wood_runiverse_dependencies, universe = "tidyverse")
test_param_runiverse(wood_runiverse_dependencies, package = "ggplot2")
test_param_package(wood_runiverse_dependencies(package = "ggplot2", universe = "tidyverse"))
test_param_runiverse(wood_runiverse_dependencies(package = "ggplot2", universe = "tidyverse"))

test_that("raises an exception if package not available", {
expect_error(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-runiverse-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("v", {
# TESTS ----
test_packages(tidyverse_packages)
test_cache({ wood_runiverse_packages(universe = "tidyverse") }, tidyverse_packages)
test_param_runiverse(wood_runiverse_packages)
test_param_runiverse(wood_runiverse_packages(universe = "tidyverse"))

test_that("tidyverse universe has ggplot2 package", {
expect_subset("ggplot2", tidyverse_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-runiverse-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("w", {
# TESTS ----
test_version(versionsort_version)
test_cache({ wood_runiverse_version("versionsort", "turtletopia") }, versionsort_version)
test_param_package(wood_runiverse_version, universe = "turtletopia")
test_param_runiverse(wood_runiverse_version, package = "versionsort")
test_param_package(wood_runiverse_version(package = "versionsort", universe = "turtletopia"))
test_param_runiverse(wood_runiverse_version(package = "versionsort", universe = "turtletopia"))

test_that("raises an exception if package not available", {
expect_error(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-url-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("x", {
# TESTS ----
test_dependencies(dockerfiler_deps)
test_cache({ wood_url_dependencies("dockerfiler", "https://colinfay.me") }, dockerfiler_deps)
test_param_package(wood_url_dependencies, repository = "https://colinfay.me")
test_param_url_repo(wood_url_dependencies, package = "dockerfiler")
test_param_package(wood_url_dependencies(package = "dockerfiler", repository = "https://colinfay.me"))
test_param_url_repo(wood_url_dependencies(package = "dockerfiler", repository = "https://colinfay.me"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-url-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("y", {
# TESTS ----
test_packages(cynkra_packages)
test_cache({ wood_url_packages("https://cynkra.r-universe.dev") }, cynkra_packages)
test_param_url_repo(wood_url_packages)
test_param_url_repo(wood_url_packages(repository = "https://cynkra.r-universe.dev"))

test_that("Cynkra repository has cynkrathis package", {
expect_subset("cynkrathis", cynkra_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-url-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("x", {
# TESTS ----
test_version(dockerfiler_version)
test_cache({ wood_url_version("dockerfiler", "https://colinfay.me") }, dockerfiler_version)
test_param_package(wood_url_version, repository = "https://colinfay.me")
test_param_url_repo(wood_url_version, package = "dockerfiler")
test_param_package(wood_url_version(package = "dockerfiler", repository = "https://colinfay.me"))
test_param_url_repo(wood_url_version(package = "dockerfiler", repository = "https://colinfay.me"))

skip_if_offline()
test_that("raises an exception if package not available", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-wood-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ with_mock_dir("z", {

# TESTS ----
test_list_of(mixed_deps, pkgs, test_dependencies)
test_param_packages(wood_dependencies)
test_param_repos(wood_dependencies, packages = c("versionsort", "gglgbtq"))
test_param_packages(wood_dependencies(packages = c("versionsort", "gglgbtq")))
test_param_repos(wood_dependencies(packages = c("versionsort", "gglgbtq")))

test_that("returns a 'wood_dep_list' object", {
expect_s3_class(mixed_deps, "wood_dep_list")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-wood-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with_mock_dir("1", {

# TESTS ----
test_packages(packages)
test_param_repos(wood_packages)
test_param_repos(wood_packages())

test_that("uppercase in URL is preserved", {
expect_not_empty(colinfay_packages)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-wood-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ with_mock_dir("2", {

# TESTS ----
test_list_of(mixed_versions, pkgs, test_versions)
test_param_packages(wood_versions)
test_param_repos(wood_versions, packages = c("versionsort", "gglgbtq"))
test_param_packages(wood_versions(packages = c("versionsort", "gglgbtq")))
test_param_repos(wood_versions(packages = c("versionsort", "gglgbtq")))

# TODO: maybe add test whether version codes are sorted?

0 comments on commit 0017b31

Please sign in to comment.