Skip to content

Commit e3eebfc

Browse files
committed
edit glue tests to expect pass-through instead of error
1 parent 34d87bf commit e3eebfc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tests/testthat/test-glue_label_brief.R

+18-8
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,19 @@ test_that("label supports glue syntax for {.seg_val} {.seg_col} {.step} {.col}",
6767
test_that("glue scope doesn't expose internal variables", {
6868

6969
# Ex: should not be able to access `columns` local variable in `col_vals_lt()`
70-
expect_error(create_agent(small_table) %>% col_vals_lt(c, 8, label = "{columns}"))
70+
expect_identical(
71+
create_agent(small_table) %>%
72+
col_vals_lt(c, 8, label = "{columns}") %>%
73+
{.$validation_set$label},
74+
"{columns}"
75+
)
7176
# Ex: should not be able to access `i` local variable in `create_validation_step()`
72-
expect_error(create_agent(small_table) %>% col_vals_lt(c, 8, label = "{i}"))
77+
expect_identical(
78+
create_agent(small_table) %>%
79+
col_vals_lt(c, 8, label = "{i}") %>%
80+
{.$validation_set$label},
81+
"{i}"
82+
)
7383

7484
# Should be able to access global vars/fns
7585
expect_equal(
@@ -83,23 +93,23 @@ test_that("glue scope doesn't expose internal variables", {
8393

8494
test_that("glue env searches from the caller env of the validation function", {
8595

86-
to_upper <- function(x) stop("Oh no!")
96+
to_upper <- function(x) "global"
8797

88-
expect_error(
98+
expect_identical(
8999
create_agent(small_table) %>%
90100
col_vals_lt(c, 8, label = "{to_upper(.col)}") %>%
91101
{.$validation_set$label},
92-
"Oh no!"
102+
"global"
93103
)
94104

95-
expect_equal(
105+
expect_identical(
96106
local({
97-
to_upper <- function(x) toupper(x)
107+
to_upper <- function(x) "local"
98108
create_agent(small_table) %>%
99109
col_vals_lt(c, 8, label = "{to_upper(.col)}") %>%
100110
{.$validation_set$label}
101111
}),
102-
"C"
112+
"local"
103113
)
104114

105115
})

0 commit comments

Comments
 (0)