Skip to content

Commit

Permalink
✅ Add unit test for get_datafield_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Jan 27, 2025
1 parent efaa036 commit 9ee63d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/get_datafield_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ table in that datasource and which field in that table.",
source = "data source which stores the data"
)
)
return(1)
return(1L)
}
datafield <- verify_vc(
file = "datafield", root = root,
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test_aaa_get_datafield_id.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("get_datafield_id", {
root <- tempfile("get_datafield_id")
dir.create(root)
on.exit(unlink(root, recursive = TRUE))

expect_is(
get_datafield_id(
table = "test", field = "id", datasource = "database", root = root
),
"integer"
)
expect_is(
get_datafield_id(
table = "test", field = "id", datasource = "database", root = root
),
"integer"
)
expect_is(
get_datafield_id(
table = "test2", field = "id", datasource = "database", root = root
),
"integer"
)
})

0 comments on commit 9ee63d5

Please sign in to comment.