Skip to content

Commit a1dbd20

Browse files
committed
Correctly handle null value
And mock function to test no quarto installed
1 parent 1292828 commit a1dbd20

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Suggests:
2727
curl,
2828
knitr,
2929
rsconnect (>= 0.8.26),
30-
testthat (>= 3.1.0),
30+
testthat (>= 3.1.7),
3131
withr,
3232
xfun
3333
VignetteBuilder:

R/quarto.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ check_quarto_version <- function(ver, what, url) {
124124
#' @export
125125
quarto_binary_sitrep <- function(verbose = TRUE, debug = FALSE) {
126126

127-
quarto_found <- normalizePath(quarto_path(), mustWork = FALSE)
127+
quarto_found <- quarto_path()
128128
if (is.null(quarto_found)) {
129129
if (verbose) {
130130
cli::cli_alert_danger(quarto_not_found_msg)
131131
}
132132
return(FALSE)
133133
}
134134

135+
quarto_found <- normalizePath(quarto_found, mustWork = FALSE)
136+
135137
same_config <- TRUE
136138
if (debug) verbose <- TRUE
137139

tests/testthat/_snaps/quarto.md

+9
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,12 @@
7777
Output
7878
[1] TRUE
7979

80+
---
81+
82+
Code
83+
quarto_binary_sitrep(debug = TRUE)
84+
Message
85+
x Quarto command-line tools path not found! Please make sure you have installed and added Quarto to your PATH or set the QUARTO_PATH environment variable.
86+
Output
87+
[1] FALSE
88+

tests/testthat/test-quarto.R

+8
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@ test_that("quarto CLI sitrep", {
6565
transform = transform_quarto_cli_in_output(full_path = TRUE, normalize_path = TRUE)
6666
)
6767
)
68+
69+
# Mock no quarto found
70+
with_mocked_bindings(
71+
quarto_path = function(...) NULL,
72+
expect_snapshot(
73+
quarto_binary_sitrep(debug = TRUE)
74+
)
75+
)
6876
})

0 commit comments

Comments
 (0)