@@ -2,64 +2,61 @@ context("logger_config")
22
33
44test_that(" logger_config works as expected" , {
5-
65 cfg <- logger_config(
76 appenders = Appender $ new(),
87 propagate = FALSE ,
98 exception_handler = default_exception_handler ,
109 threshold = NA ,
1110 filters = FilterForceLevel $ new(" info" )
1211 )
12+ expect_s3_class(cfg , " logger_config" )
1313
1414 tl <- get_logger(" test" )$ config(cfg )
15-
1615 expect_true(inherits(tl $ appenders [[1 ]], " Appender" ))
16+ expect_false(is_virgin_Logger(tl ))
1717
18- tl <- get_logger $ config(basic_config())
19-
20-
18+ tl <- get_logger(" test" )$ config(logger_config())
19+ expect_true(is_virgin_Logger(tl ))
2120})
2221
2322
2423
25- test_that(" as_logger_config works as expected" , {
24+
25+ test_that(" as_logger_config works as expected with YAML file" , {
2626 ty <- rprojroot :: find_testthat_root_file(" testdata" , " lg_full.yaml" )
2727 cfg <- as_logger_config(ty )
28+ expect_s3_class(cfg , " logger_config" )
2829
2930 expect_identical(cfg $ appenders [[1 ]]$ layout $ fmt , " %L %t - %m" )
30- expect_true(is_Logger( cfg ) )
31+ expect_s3_class( cfg , " logger_config " )
3132})
3233
3334
3435
3536
36- test_that(" setting logger$config works as expected " , {
37+ test_that(" setting logger$config fails if yaml file is passed to `text` instead of `file` " , {
3738 ty <- rprojroot :: find_testthat_root_file(" testdata" , " lg_full.yaml" )
3839 lg <- get_logger(" test" )
39-
40- lg $ config(ty )
41- lg $ config(file = ty )
4240 expect_error(lg $ config(text = ty ), " YAML" )
4341})
4442
4543
4644
4745
48- test_that(" logger_config works for simplified logger config" , {
46+ test_that(" as_logger_config works for simplified yaml logger config" , {
4947 ty <- rprojroot :: find_testthat_root_file(" testdata" , " lg_simple.yaml" )
5048 cfg <- as_logger_config(ty )
49+ expect_s3_class(cfg , " logger_config" )
5150
5251 expect_identical(cfg $ appenders [[1 ]]$ layout $ fmt , " %L %t - %m" )
53- expect_true(is_Logger( cfg ) )
52+ expect_s3_class( cfg , " logger_config " )
5453})
5554
5655
5756
5857
59- test_that(" resolve_r6_ctors" , {
60-
58+ test_that(" resolve_r6_ctors works as expected" , {
6159 tf <- tempfile()
62-
6360 x <- list (
6461 " Logger" = list (
6562 name = " test" ,
@@ -70,14 +67,13 @@ test_that("resolve_r6_ctors", {
7067 )
7168 )
7269 )
73-
7470 res <- resolve_r6_ctors(x )
7571 expect_true(is_Logger(res ))
72+ expect_s3_class(as_logger_config(res ), " logger_config" )
7673 expect_identical(res $ appenders [[1 ]]$ file , tf )
7774
7875
7976 tf <- tempfile()
80-
8177 x <- list (
8278 " Logger" = list (
8379 name = " test2" ,
@@ -96,5 +92,6 @@ test_that("resolve_r6_ctors", {
9692
9793 res <- resolve_r6_ctors(x )
9894 expect_true(is_Logger(res ))
95+ expect_s3_class(as_logger_config(res ), " logger_config" )
9996 expect_identical(res $ appenders [[1 ]]$ appenders [[1 ]]$ file , tf )
10097})
0 commit comments