Skip to content

Commit

Permalink
test(quarto/files): remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
mutlusun committed Nov 8, 2024
1 parent 8116117 commit 8309533
Showing 1 changed file with 1 addition and 90 deletions.
91 changes: 1 addition & 90 deletions tests/testthat/test-tar_quarto_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ targets::tar_test("tar_quarto_files() project", {
}
})

targets::tar_test("tar_quarto_files() detects non-code dependencies", {
targets::tar_test("tar_quarto_files() detects nested dependencies", {
skip_quarto()
fs::dir_create("report")
fs::dir_create(file.path("report", "subdir"))
Expand Down Expand Up @@ -192,92 +192,3 @@ targets::tar_test("tar_quarto_files() detects custom output file", {
expect_equal(out$output, "custom.html")
expect_equal(out$input, character(0))
})

targets::tar_test("tar_quarto_files() detects code dependencies", {
skip_quarto()
fs::dir_create("report")
fs::dir_create(file.path("report", "subdir"))
lines <- c(
"---",
"title: main",
"output_format: html",
"---",
"",
"{{< include \"text1.qmd\" >}}",
"",
"{{< include \"subdir/text2.qmd\" >}}"
)
writeLines(lines, file.path("report", "main.qmd"))
lines <- c(
"# First File",
"",
"Contains a code cell.",
"",
"```{r}",
"1 + 1",
"```"
)
writeLines(lines, file.path("report", "text1.qmd"))
lines <- c(
"# Second File",
"",
"Contains a code cell with a call to `tar_read`.",
"",
"```{r}",
"targets::tar_read(mytarget)",
"```"
)
writeLines(lines, file.path("report", "subdir", "text2.qmd"))
out <- tar_quarto_files("report/main.qmd")
if (identical(tolower(Sys.info()[["sysname"]]), "windows")) {
expect_equal(
sort(basename(out$sources)),
sort("text1.qmd", "text2.qmd")
)
expect_equal(basename(out$output), "main.html")
} else {
expect_equal(
out$sources,
sort(
c(
file.path("report", c("text1.qmd", "main.qmd")),
file.path("report", "subdir", "text2.qmd")
)
)
)
expect_equal(out$output, file.path("report", "main.html"))
}
expect_equal(out$input, character())
# Check whether we get the same result when calling via a project.
lines <- c(
"project:",
" output-dir: myoutdir",
" render:",
" - main.qmd"
)
writeLines(lines, file.path("report", "_quarto.yml"))
out <- tar_quarto_files("report/")
if (identical(tolower(Sys.info()[["sysname"]]), "windows")) {
expect_equal(
sort(basename(out$sources)),
sort("main.qmd", "text1.qmd", "text2.qmd")
)
expect_equal(basename(out$output), "myoutdir")
expect_equal(basename(out$input), "_quarto.yml")
} else {
expect_equal(
out$sources,
sort(
c(
file.path("report", c("text1.qmd", "main.qmd")),
file.path("report", "subdir", "text2.qmd")
)
)
)
expect_equal(out$output, file.path("report", "myoutdir"))
expect_equal(
out$input,
file.path("report", "_quarto.yml")
)
}
})

0 comments on commit 8309533

Please sign in to comment.