Skip to content

Commit 3af4119

Browse files
committed
update testpkg.R to include 'step_days'; closes #2
1 parent a6bb011 commit 3af4119

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: githist
22
Title: Code analyses traced along the 'git' history of a package
3-
Version: 0.1.0.037
3+
Version: 0.1.0.038
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/githist",
99
"issueTracker": "https://github.com/ropensci-review-tools/githist/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.0.037",
11+
"version": "0.1.0.038",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

tests/testthat/test-testpkg.R

+16-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_that ("testpkg and input errors", {
99
expect_error (githist (path, step_size = 1:2, num_cores = 1L))
1010
expect_error (githist (path, step_size = "1", num_cores = 1L))
1111

12-
res <- githist (path, num_cores = 1L)
12+
res <- githist (path, num_cores = 1L, step_days = 0L)
1313
fs::dir_delete (path)
1414

1515
expect_type (res, "list")
@@ -23,27 +23,28 @@ test_that ("githist parameters", {
2323
flist <- unzip (pkg, exdir = fs::path_temp ())
2424
path <- fs::path_dir (flist [1])
2525

26-
res0 <- githist (path, num_cores = 1L)
27-
n0 <- vapply (res0, nrow, integer (1L))
26+
res0 <- githist (path, step_days = 0L, num_cores = 1L)
2827
fs::dir_delete (path)
2928

3029
flist <- unzip (pkg, exdir = fs::path_temp ())
31-
res1 <- githist (path, n = 2L, num_cores = 1L)
32-
n1 <- vapply (res1, nrow, integer (1L))
30+
res1 <- githist (path, n = 2L, step_days = 0L, num_cores = 1L)
3331
fs::dir_delete (path)
3432

33+
n0 <- vapply (res0, nrow, integer (1L))
34+
n1 <- vapply (res1, nrow, integer (1L))
35+
expect_true (all (n0 > n1))
36+
# `n = 2L` selects dates [1:2] from original data:
37+
expect_identical (res0$desc_data$date [1:2], res1$desc_data$date)
38+
3539
flist <- unzip (pkg, exdir = fs::path_temp ())
36-
res2 <- githist (path, n = 2L, step_size = 2L, num_cores = 1L)
37-
n2 <- vapply (res2, nrow, integer (1L))
40+
res2 <- githist (path, n = 2L, step_days = 1L, num_cores = 1L)
3841
fs::dir_delete (path)
3942

40-
expect_true (all (n0 > n1))
43+
n2 <- vapply (res2, nrow, integer (1L))
4144
expect_true (all (n0 > n2))
42-
expect_true (nrow (res0$desc_data) > 2L)
43-
expect_equal (nrow (res1$desc_data), 2L)
44-
expect_equal (nrow (res2$desc_data), 2L)
45-
46-
d1 <- abs (diff (res1$desc_data$date, units = "s"))
47-
d2 <- abs (diff (res2$desc_data$date, units = "s"))
48-
expect_true (mean (d1) < mean (d2))
45+
expect_true (all (n1 > n2))
46+
expect_equal (
47+
length (res2$desc_dat$date),
48+
length (unique (res2$desc_data$date))
49+
)
4950
})

0 commit comments

Comments
 (0)