diff --git a/dev/flat_inflate_all.Rmd b/dev/flat_inflate_all.Rmd index d840903..fe35619 100644 --- a/dev/flat_inflate_all.Rmd +++ b/dev/flat_inflate_all.Rmd @@ -1037,6 +1037,50 @@ usethis::with_project(dummypackage, { ) }) + # We add a "real" unit test in our flat file to reach a 100% coverage + flat_content <- readLines(dev_file1) + flat_content[grepl("expect_true", flat_content)] <- "expect_equal(flat1_rmd(), 1)" + writeLines(flat_content, dev_file1) + + capture.output( + inflate_all( + pkg = dummypackage, + check = FALSE, + codecov = TRUE + ), + file = console_output_file, + type = "message" + ) + + test_that("inflate outputs compute codecov correctly", { + res <- readLines(console_output_file) + + expect_true( + any(grepl( + pattern = "Computing code coverage - it might take some time", + x = res + )) + ) + + expect_true( + any(grepl( + pattern = "R/flat1_rmd.R: 100.00%", + x = res + )) + ) + + + expect_true( + any(grepl( + pattern = paste( + basename(dummypackage), + "Coverage: 100.00%" + ), + x = res + )) + ) + }) + capture.output( inflate_all( check = FALSE, @@ -1046,6 +1090,7 @@ usethis::with_project(dummypackage, { type = "message" ) + test_that("inflate does not compute codecov if not asked", { res <- readLines(console_output_file) diff --git a/tests/testthat/test-inflate-part3.R b/tests/testthat/test-inflate-part3.R index 1bda345..59fae30 100644 --- a/tests/testthat/test-inflate-part3.R +++ b/tests/testthat/test-inflate-part3.R @@ -96,6 +96,10 @@ usethis::with_project(dummypackage, { ) }) + # We add a "real" unit test in our flat file to reach a 100% coverage + flat_content <- readLines(dev_file1) + flat_content[grepl("expect_true", flat_content)] <- "expect_equal(flat1_rmd(), 1)" + writeLines(flat_content, dev_file1) capture.output( inflate( @@ -111,6 +115,35 @@ usethis::with_project(dummypackage, { file = console_output_file, type = "message" ) + + test_that("inflate outputs compute codecov correctly", { + res <- readLines(console_output_file) + + expect_true( + any(grepl( + pattern = "Computing code coverage - it might take some time", + x = res + )) + ) + + expect_true( + any(grepl( + pattern = "R/flat1_rmd.R: 100.00%", + x = res + )) + ) + + + expect_true( + any(grepl( + pattern = paste( + basename(dummypackage), + "Coverage: 100.00%" + ), + x = res + )) + ) + }) }) unlink(console_output_file) diff --git a/tests/testthat/test-inflate_all.R b/tests/testthat/test-inflate_all.R index 5cc4438..08aabf7 100644 --- a/tests/testthat/test-inflate_all.R +++ b/tests/testthat/test-inflate_all.R @@ -750,6 +750,50 @@ usethis::with_project(dummypackage, { ) }) + # We add a "real" unit test in our flat file to reach a 100% coverage + flat_content <- readLines(dev_file1) + flat_content[grepl("expect_true", flat_content)] <- "expect_equal(flat1_rmd(), 1)" + writeLines(flat_content, dev_file1) + + capture.output( + inflate_all( + pkg = dummypackage, + check = FALSE, + codecov = TRUE + ), + file = console_output_file, + type = "message" + ) + + test_that("inflate outputs compute codecov correctly", { + res <- readLines(console_output_file) + + expect_true( + any(grepl( + pattern = "Computing code coverage - it might take some time", + x = res + )) + ) + + expect_true( + any(grepl( + pattern = "R/flat1_rmd.R: 100.00%", + x = res + )) + ) + + + expect_true( + any(grepl( + pattern = paste( + basename(dummypackage), + "Coverage: 100.00%" + ), + x = res + )) + ) + }) + capture.output( inflate_all( check = FALSE, @@ -759,6 +803,7 @@ usethis::with_project(dummypackage, { type = "message" ) + test_that("inflate does not compute codecov if not asked", { res <- readLines(console_output_file)