tests/testthat/test-blocks.R

context("Blocks")

test_that("deleting blocks", {
    withr::with_tempfile("block", {
        con <- file(block, open = "a")
        writeLines("blank space", con = con)
        writeLines(glue::glue("## test cabinet start"), con = con)
        writeLines("Text to delete", con = con)
        writeLines(glue::glue("## test cabinet end"), con = con)
        writeLines("blank space", con = con)
        close(con)

        expect_equal(read_utf8(block),
                     c("blank space", "## test cabinet start",
                       "Text to delete", "## test cabinet end",
                       "blank space"))
        block_delete("## test cabinet start", "## test cabinet end", block)
        expect_equal(read_utf8(block), c("blank space", "blank space"))
    }, fileext = "txt")
})

Try the cabinets package in your browser

Any scripts or data that you put into this service are public.

cabinets documentation built on Nov. 8, 2020, 4:32 p.m.