Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module()$datanames : unify combined_datanames no matter what's the length of transformers #1344

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module <- function(label = "module",
}
checkmate::assert_list(transformers, types = "teal_transform_module")
transformer_datanames <- unlist(lapply(transformers, attr, "datanames"))
combined_datanames <- if (identical(datanames, "all") || identical(transformer_datanames, "all")) {
combined_datanames <- if (identical(datanames, "all") || any(sapply(transformer_datanames, identical, "all"))) {
"all"
} else {
union(datanames, transformer_datanames)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ testthat::test_that("module datanames is appended by its transformers datanames"
testthat::expect_identical(out$datanames, c("c", "a", "b"))
})

testthat::test_that("module datanames is set to 'all' if transformer $datanames is 'all'", {
testthat::test_that("module datanames is set to union(datanames, 'all') if transformer $datanames is 'all'", {
m7pr marked this conversation as resolved.
Show resolved Hide resolved
transformer_w_datanames <- teal_transform_module(
ui = function(id) NULL,
server = function(id, data) {
Expand All @@ -551,7 +551,7 @@ testthat::test_that("module datanames is set to 'all' if transformer $datanames
)

out <- module(datanames = "c", transformers = list(transformer_w_datanames))
testthat::expect_identical(out$datanames, "all")
testthat::expect_identical(out$datanames, c("c", "all"))
m7pr marked this conversation as resolved.
Show resolved Hide resolved
})

testthat::test_that("module datanames stays 'all' regardless of transformers", {
Expand Down
Loading