Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mighty.component
Title: Mighty Components for ADaM Generation
Version: 0.0.0.9017
Version: 0.0.0.9018
Authors@R: c(
person("Aksel", "Thomsen", , "oath@enovonordisk.com", role = c("aut", "cre")),
person("Matthew", "Phelps", , "mewp@enovonordisk.com", role = c("aut")),
Expand Down
14 changes: 13 additions & 1 deletion R/mighty_component.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,26 @@ tags_to_params <- function(tags) {
tags_to_depends <- function(tags) {
i <- regexpr(pattern = " +", text = tags)

data.frame(
depends <- data.frame(
domain = tags |>
substr(start = 1, stop = i - 1) |>
trimws(),
column = tags |>
substr(start = i + 1, stop = nchar(tags)) |>
trimws()
)

mistakes <- tags[!nchar(depends$domain) | !nchar(depends$column)]
if (length(mistakes)) {
cli::cli_abort(
c(
"All {.code @depends} tags must have both a domain and column:",
"x" = "Not valid: {.code {mistakes}}"
)
)
}

depends
}

#' @noRd
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_components/test_coverage.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @description
#' This is a test component used for unit testing the workflow and coverage.
#' @param value to assign to x
#' @depends limit
#' @depends domain limit
#' @type derivation
#' @code
x <- {{ value }}
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-mighty_component.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ test_that("tags_to_depends", {
expect_named(c("domain", "column")) |>
nrow() |>
expect_equal(0)

tags_to_depends("USUBJID") |>
expect_error("must have both a domain and column")

tags_to_depends(c("data1 var1", "USUBJID")) |>
expect_error("must have both a domain and column")
})

test_that("print", {
Expand Down
Loading