|
1 | 1 | # --------------------------------------------------------# |
2 | 2 | # Helper: Count cache entry files, excluding graph.rds |
3 | 3 | # --------------------------------------------------------# |
4 | | -count_cache_entries <- function(cache_dir, backend_pattern = "\\.(rds|qs)$") { |
| 4 | +count_cache_entries <- function(cache_dir, backend_pattern = "\\.(rds|qs2)$") { |
5 | 5 | files <- list.files(cache_dir, pattern = backend_pattern) |
6 | 6 | length(files[!grepl("^graph\\.rds", files)]) |
7 | 7 | } |
@@ -112,28 +112,28 @@ test_that("cacheFile tracks multiple dir arguments and vector paths", { |
112 | 112 | }) |
113 | 113 |
|
114 | 114 | # --------------------------------------------------------# |
115 | | -test_that("cacheFile works with 'qs' backend", { |
116 | | - skip_if_not_installed("qs") |
| 115 | +test_that("cacheFile works with 'qs2' backend", { |
| 116 | + skip_if_not_installed("qs2") |
117 | 117 | if (exists("cacheTree_reset", mode = "function")) cacheTree_reset() |
118 | 118 |
|
119 | | - cache_dir <- file.path(tempdir(), "cache_qs_backend") |
| 119 | + cache_dir <- file.path(tempdir(), "cache_qs2_backend") |
120 | 120 | unlink(cache_dir, recursive = TRUE) |
121 | 121 | dir.create(cache_dir, showWarnings = FALSE) |
122 | 122 |
|
123 | | - f <- cacheFile(cache_dir, backend = "qs") %@% function(x) { |
| 123 | + f <- cacheFile(cache_dir, backend = "qs2") %@% function(x) { |
124 | 124 | x * 2 |
125 | 125 | } |
126 | 126 |
|
127 | 127 | res <- f(10) |
128 | 128 | expect_equal(res, 20) |
129 | 129 |
|
130 | | - # Verify the file extension is actually .qs |
| 130 | + # Verify the file extension is actually .qs2 |
131 | 131 | files <- list.files(cache_dir) |
132 | | - expect_true(any(grepl("\\.qs$", files))) |
133 | | - |
| 132 | + expect_true(any(grepl("\\.qs2$", files))) |
| 133 | + |
134 | 134 | # Verify we can load it back manually |
135 | 135 | cache_path <- file.path(cache_dir, files[1]) |
136 | | - loaded <- qs::qread(cache_path) |
| 136 | + loaded <- qs2::qs_read(cache_path) |
137 | 137 | expect_equal(loaded$value, 20) |
138 | 138 | }) |
139 | 139 |
|
@@ -297,11 +297,11 @@ test_that("backend selection works", { |
297 | 297 | cached_rds(1) |
298 | 298 | expect_true(any(grepl("\\.rds$", list.files(cache_dir)))) |
299 | 299 |
|
300 | | - # QS |
301 | | - if (requireNamespace("qs", quietly = TRUE)) { |
302 | | - cached_qs <- cacheFile(cache_dir, backend = "qs") %@% function(x) x |
303 | | - cached_qs(2) |
304 | | - expect_true(any(grepl("\\.qs$", list.files(cache_dir)))) |
| 300 | + # QS2 |
| 301 | + if (requireNamespace("qs2", quietly = TRUE)) { |
| 302 | + cached_qs2 <- cacheFile(cache_dir, backend = "qs2") %@% function(x) x |
| 303 | + cached_qs2(2) |
| 304 | + expect_true(any(grepl("\\.qs2$", list.files(cache_dir)))) |
305 | 305 | } |
306 | 306 | }) |
307 | 307 |
|
@@ -1507,7 +1507,7 @@ test_that("cache_stats returns correct aggregate statistics", { |
1507 | 1507 | st2 <- cache_stats(tmp) |
1508 | 1508 | expect_equal(st2$n_entries, 3L) |
1509 | 1509 | # Files are small, so total_size_mb may round to 0 — check raw file sizes instead |
1510 | | - files <- list.files(tmp, pattern = "\\.(rds|qs)$", full.names = TRUE) |
| 1510 | + files <- list.files(tmp, pattern = "\\.(rds|qs2)$", full.names = TRUE) |
1511 | 1511 | files <- files[!grepl("graph\\.rds$", files)] |
1512 | 1512 | expect_true(sum(file.size(files)) > 0) |
1513 | 1513 | expect_true(!is.na(st2$oldest)) |
@@ -1616,7 +1616,7 @@ test_that(".load_cacheR_config does not override existing options", { |
1616 | 1616 | on.exit(unlink(tmp, recursive = TRUE)) |
1617 | 1617 |
|
1618 | 1618 | yml_path <- file.path(tmp, ".cacheR.yml") |
1619 | | - writeLines("backend: qs", yml_path) |
| 1619 | + writeLines("backend: qs2", yml_path) |
1620 | 1620 |
|
1621 | 1621 | withr::with_options(list(cacheR.backend = "rds"), { |
1622 | 1622 | cacheR:::.load_cacheR_config(yml_path) |
|
0 commit comments