From 402bf42b80e7b0ce9923a356d24049c6f5643794 Mon Sep 17 00:00:00 2001 From: MEO265 <99362508+MEO265@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:40:56 +0200 Subject: [PATCH] tests: Add tests for `set_echo` --- tests/testthat/test-configurations.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/testthat/test-configurations.R b/tests/testthat/test-configurations.R index 83eac26..458753f 100644 --- a/tests/testthat/test-configurations.R +++ b/tests/testthat/test-configurations.R @@ -27,3 +27,16 @@ test_that("test timestamp configuration", { expect_silent(set_timestamp_format(ts_format = old, confirm = FALSE)) expect_identical(get_timestamp_format(), old) }) + +test_that("test echo configuration", { + old <- get_echo() + on.exit(set_echo(old, confirm = FALSE)) + + expect_message(set_echo(echo = TRUE), regexp = "Echo set to TRUE.") + expect_output(message("test"), regexp = "\"test\\n\"" , fixed = TRUE) + expect_output(message("test", echo = FALSE), regexp = NA) + + expect_silent(set_echo(echo = FALSE, confirm = FALSE)) + expect_output(message("test", echo = TRUE), regexp = "\"test\\n\"" , fixed = TRUE) + expect_output(message("test"), regexp = NA) +})