From f259c2f79a9704a06f8b8e2942cd60c0dfbaec30 Mon Sep 17 00:00:00 2001 From: mpadge Date: Thu, 14 Mar 2024 10:04:07 +0100 Subject: [PATCH] add tests --- DESCRIPTION | 5 ++++- codemeta.json | 2 +- tests/testthat.R | 12 ++++++++++++ tests/testthat/test-editors.R | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-editors.R diff --git a/DESCRIPTION b/DESCRIPTION index 7341e96..8a6e8c7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.0.3.001 +Version: 0.0.3.002 Authors@R: person(given = "First", family = "Last", @@ -16,3 +16,6 @@ Imports: License: MIT + file LICENSE Encoding: UTF-8 RoxygenNote: 7.3.1 +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 diff --git a/codemeta.json b/codemeta.json index 4fcb4be..c37592d 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "name": "dashboard: What the Package Does (One Line, Title Case)", "codeRepository": "https://github.com/ropensci-review-tools/dashboard", "license": "https://spdx.org/licenses/MIT", - "version": "0.0.3.001", + "version": "0.0.3.002", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..42b97a3 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library (testthat) +library (dashboard) + +test_check ("dashboard") diff --git a/tests/testthat/test-editors.R b/tests/testthat/test-editors.R new file mode 100644 index 0000000..9877574 --- /dev/null +++ b/tests/testthat/test-editors.R @@ -0,0 +1,23 @@ +test_that ("editor names", { + + q <- gh_editors_team_qry (stats = FALSE) + editors <- gh::gh_gql (query = q) + editors <- editors$data$organization$team$members$nodes + expect_true (length (editors) > 10L) + nms <- unique (unlist (lapply (editors, names))) + expect_identical (nms, "login") # should have 'login' only + editors <- vapply (editors, function (i) i$login, character (1L)) + expect_type (editors, "character") + expect_true (length (editors) > 10L) + + q <- gh_editors_team_qry (stats = TRUE) + editors_stats <- gh::gh_gql (query = q) + editors_stats <- editors_stats$data$organization$team$members$nodes + expect_true (length (editors_stats) > 5L) + expect_true (length (editors_stats) < length (editors)) + nms <- unique (unlist (lapply (editors_stats, names))) + expect_identical (nms, "login") # should have 'login' only + editors_stats <- vapply (editors_stats, function (i) i$login, character (1L)) + expect_type (editors_stats, "character") + expect_true (length (editors_stats) > 5L) +})