Skip to content

Commit

Permalink
Merge pull request #276 from mstackhouse/gh_issue_275
Browse files Browse the repository at this point in the history
Closes #275
  • Loading branch information
elimillera authored Dec 10, 2024
2 parents fc52f00 + 16f2e5e commit 29f6c78
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/type.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ xportr_type <- function(.df,
}

metacore <- metadata %>%
select(!!sym(variable_name), !!sym(type_name))
select(variable = !!sym(variable_name), type = !!sym(type_name))

# Common check for multiple variables name
check_multiple_var_specs(metadata, variable_name)
Expand All @@ -129,7 +129,7 @@ xportr_type <- function(.df,
# Produces a data.frame with Variables, Type.x(Table), and Type.y(metadata)
meta_ordered <- left_join(
data.frame(variable = names(.df), type = unlist(table_cols_types)),
metadata,
metacore,
by = "variable"
) %>%
mutate(
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,23 @@ test_that("type Test 11: Works as expected with only one domain in metadata", {

expect_equal(xportr_type(adsl, metadata), adsl)
})

# xportr_type ----
## Test 12: xportr_type: xportr_options() overrides work properly ----
test_that("type Test 12: xportr_options() overrides work properly", {
op <- options()

data("adsl_xportr", "var_spec", package = "xportr")
var_spec <- distinct(var_spec, Variable, .keep_all = TRUE) # quick fix because there's dups in the data

xportr_options(
xportr.variable_name = "Variable",
xportr.type_name = "Data Type"
)

expect_silent(
adsl_xportr %>% xportr_type(var_spec, "ADSL", "message")
)

options(op)
})

0 comments on commit 29f6c78

Please sign in to comment.