tests/testthat/test_log_to_r_console.R

context("log_to_r_console")

test_that("logging events", {capture.output({

  expect_error(fixed = TRUE,
    shinyEventLogger:::log_to_file(),
    "A header of log entry is missing."
    )

  expect_message(fixed = TRUE,
    shinyEventLogger:::log_to_r_console(header = "|#-1|EVENT||DONE|"),
    "|#-1|EVENT||DONE|"
    )

  expect_output(fixed = TRUE,
    shinyEventLogger:::log_to_r_console(header = "|#-1|EVENT||DONE|",
                                        body = "|#-1|First line\n"),
    "|#-1|First line"
    )

  expect_message(fixed = TRUE,
    shinyEventLogger:::log_to_r_console(header = "|#-1|EVENT||DONE|",
                                        body = "|#-1|First line\n"),
    "|#-1|EVENT||DONE|"
    )

})})

test_that("returned values", {capture.output({

  expect_identical(
    shinyEventLogger:::log_to_r_console(header = "|#-1|EVENT||DONE|"),
    "|#-1|EVENT||DONE|"
    )

  expect_identical(
    shinyEventLogger:::log_to_r_console(header = "|#-1|EVENT||DONE|",
                                        body = "|#-1|First line\n"),
    "|#-1|EVENT||DONE|\n|#-1|First line\n"
    )

})})

Try the shinyEventLogger package in your browser

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

shinyEventLogger documentation built on May 1, 2019, 9:26 p.m.