|
| 1 | +time_before_date <- Sys.Date() |
| 2 | +time_before <- as.character(time_before_date) |
| 3 | + |
1 | 4 | repo_pkg <- fake_repo(as.package = TRUE) |
2 | 5 | repo_no_pkg <- fake_repo() |
3 | 6 |
|
4 | 7 | # get_info ---- |
5 | 8 | files <- list.files(repo_pkg, recursive = TRUE) |
6 | 9 | infos <- get_info(files[grep("example", files)], repo = repo_pkg) |
7 | 10 | infos_not_in_repo <- get_info(files[grep("my_mean", files)], repo = repo_pkg) |
8 | | -today <- as.character(Sys.Date()) |
| 11 | + |
9 | 12 | # if check started one day and finishes the other day |
10 | | -tomorrow <- as.character(Sys.Date() + 1) |
| 13 | +time_after_date <- Sys.Date() |
| 14 | +time_after <- as.character(time_after_date) |
11 | 15 |
|
12 | 16 | test_that("get_info works", { |
13 | 17 | expect_true(infos$in_repository) |
14 | 18 | expect_equal(infos$file, "example.txt") |
| 19 | + |
| 20 | + expect_gte(as.Date(infos$last_modif), time_before_date) |
| 21 | + expect_lte(as.Date(infos$last_modif), time_after_date) |
15 | 22 | expect_true(as.character(as.Date(infos$first_modif)) %in% |
16 | | - c(setNames(today, "first"), setNames(tomorrow, "first"))) |
| 23 | + c(setNames(time_before, "first"), setNames(time_after, "first"))) |
17 | 24 | expect_true(as.character(as.Date(infos$last_modif)) %in% |
18 | | - c(setNames(today, "last"), setNames(tomorrow, "first"))) |
| 25 | + c(setNames(time_before, "last"), setNames(time_after, "first"))) |
19 | 26 |
|
20 | 27 | expect_false(infos_not_in_repo$in_repository) |
21 | 28 | expect_equal(infos_not_in_repo$file, "R/my_mean.R") |
22 | 29 | expect_true(is.na(infos_not_in_repo$first_modif)) |
| 30 | + expect_gte(as.Date(infos_not_in_repo$last_modif), time_before_date) |
| 31 | + expect_lte(as.Date(infos_not_in_repo$last_modif), time_after_date) |
23 | 32 | expect_true(as.character(as.Date(infos_not_in_repo$last_modif)) %in% |
24 | | - c(setNames(today, "last"), setNames(tomorrow, "first"))) |
| 33 | + c(setNames(time_before, "last"), setNames(time_after, "first"))) |
25 | 34 | }) |
26 | 35 |
|
27 | 36 | # get_last_modif ---- |
|
0 commit comments