Skip to content

Commit 1d31d61

Browse files
committed
test metrics/models_over_end_dates fns for #87
1 parent fbaeeba commit 1d31d61

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: repometrics
22
Title: Metrics for Your Code Repository
3-
Version: 0.1.5.017
3+
Version: 0.1.5.018
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
99
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.5.017",
11+
"version": "0.1.5.018",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

tests/testthat/test-cm-models.R

+23
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ test_that ("collate all models", {
9494
metrics_data <- collate_all_metrics (path, end_date = end_date)
9595
mod_dat_metrics <- collate_all_models (metrics_data = metrics_data)
9696

97+
metrics_all <- withr::with_options (
98+
list ("repometrics_period" = 365.25 / 2),
99+
metrics_over_end_dates (path, end_date = end_date, num_years = 1)
100+
)
101+
models_all <- withr::with_options (
102+
list ("repometrics_period" = 365.25 / 2),
103+
models_over_end_dates (path, end_date = end_date, num_years = 1)
104+
)
105+
97106
fs::dir_delete (path)
98107

99108
expect_type (mod_dat, "double")
@@ -103,4 +112,18 @@ test_that ("collate all models", {
103112
expect_true (length (which (is.na (mod_dat))) <= 1L)
104113

105114
expect_identical (mod_dat, mod_dat_metrics)
115+
116+
expect_type (metrics_all, "list")
117+
end_dates <- withr::with_options (
118+
list ("repometrics_period" = 365.25 / 2),
119+
get_end_date_seq (end_date = end_date, num_years = 1)
120+
)
121+
expect_length (metrics_all, length (end_dates))
122+
expect_named (metrics_all, as.character (end_dates))
123+
expect_identical (names (metrics_all [[1]]), names (metrics_data))
124+
125+
expect_s3_class (models_all, "data.frame")
126+
expect_equal (nrow (models_all), length (end_dates))
127+
model_fns <- get_cm_fns ("model")
128+
expect_named (models_all, c ("date", gsub ("cm\\_model\\_", "", model_fns)))
106129
})

0 commit comments

Comments
 (0)