/
test-find_rev.R
114 lines (87 loc) · 3.54 KB
/
test-find_rev.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# WARNING - Generated by {fusen} from dev/flat_build_envs.Rmd: do not edit by hand
testthat::test_that("find_rev returns correct nixpkgs hash", {
testthat::expect_equal(
find_rev("4.2.2"),
"8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8"
)
testthat::expect_equal(
find_rev("8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8"),
"8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8"
)
})
testthat::test_that("available_r lists all available r versions", {
testthat::expect_equal(
available_r(),
c("latest", "3.0.2", "3.0.3", "3.1.0", "3.1.2", "3.1.3", "3.2.0", "3.2.1",
"3.2.2", "3.2.3", "3.2.4", "3.3.3", "3.4.0", "3.4.1", "3.4.2", "3.4.3",
"3.4.4", "3.5.0", "3.5.1", "3.5.2", "3.5.3", "3.6.0", "3.6.1", "3.6.2",
"3.6.3", "4.0.0", "4.0.2", "4.0.3", "4.0.4", "4.1.1", "4.1.2", "4.1.3",
"4.2.0", "4.2.1", "4.2.2", "4.2.3", "4.3.1"
)
)
})
testthat::test_that("get_sri_hash_deps returns correct sri hash and dependencies of R packages", {
testthat::expect_equal(
get_sri_hash_deps("https://github.com/rap4all/housing/",
"fusen",
"1c860959310b80e67c41f7bbdc3e84cef00df18e"),
list(
"sri_hash" = "sha256-s4KGtfKQ7hL0sfDhGb4BpBpspfefBN6hf+XlslqyEn4=",
"deps" = "dplyr ggplot2 janitor purrr readxl rlang rvest stringr tidyr"
)
)
})
testthat::test_that("Snapshot test of rix()", {
save_default_nix_test <- function(ide) {
path_default_nix <- tempdir()
rix(r_ver = "4.3.1",
r_pkgs = c("dplyr", "janitor", "AER@1.2-8", "quarto"),
system_pkgs = c("quarto"),
tex_pkgs = c("amsmath"),
git_pkgs = list(
list(package_name = "housing",
repo_url = "https://github.com/rap4all/housing/",
branch_name = "fusen",
commit = "1c860959310b80e67c41f7bbdc3e84cef00df18e"),
list(package_name = "fusen",
repo_url = "https://github.com/ThinkR-open/fusen",
branch_name = "main",
commit = "d617172447d2947efb20ad6a4463742b8a5d79dc")
),
ide = ide,
project_path = path_default_nix,
overwrite = TRUE)
paste0(path_default_nix, "/default.nix")
}
testthat::announce_snapshot_file("find_rev/rstudio_default.nix")
testthat::expect_snapshot_file(
path = save_default_nix_test(ide = "rstudio"),
name = "rstudio_default.nix",
)
testthat::announce_snapshot_file("find_rev/other_default.nix")
testthat::expect_snapshot_file(
path = save_default_nix_test(ide = "other"),
name = "other_default.nix"
)
testthat::announce_snapshot_file("find_rev/code_default.nix")
testthat::expect_snapshot_file(
path = save_default_nix_test(ide = "code"),
name = "code_default.nix"
)
})
testthat::test_that("Snapshot test of rix_init()", {
save_rix_init_test <- function() {
path_env_nix <- tempdir()
rix_init(
project_path = path_env_nix,
rprofile_action = "overwrite",
message_type = "simple"
)
paste0(path_env_nix, "/.Rprofile")
}
testthat::announce_snapshot_file("find_rev/golden_Rprofile.txt")
testthat::expect_snapshot_file(
path = save_rix_init_test(),
name = "golden_Rprofile.txt",
)
})