Skip to content

Commit

Permalink
Add tests about error message for NAs
Browse files Browse the repository at this point in the history
  • Loading branch information
damianooldoni committed Oct 14, 2024
1 parent 2cb13a4 commit 093979f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/testthat/test-get_custom_effort.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
test_that("get_custom_effort() returns error if one or more deployments have NA as `start`", {
a <- mica
# One NA as ´start´
a$data$deployments$start[1] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`start` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8.")
)
# Two NAs
a$data$deployments$start[3] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`start` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 and ",
"62c200a9-0e03-4495-bcd8-032944f6f5a1.")
)
# Three NAs
a$data$deployments$start[4] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`start` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8, ",
"62c200a9-0e03-4495-bcd8-032944f6f5a1 and ",
"7ca633fa-64f8-4cfc-a628-6b0c419056d7.")
)
})

test_that("get_custom_effort() returns error if one or more deployments have NA as `end`", {
a <- mica
# One NA
a$data$deployments$end[1] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`end` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8.")
)
# Two NAs
a$data$deployments$end[3] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`end` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 and ",
"62c200a9-0e03-4495-bcd8-032944f6f5a1.")
)
# Three NAs
a$data$deployments$end[4] <- NA
expect_error(
get_custom_effort(a),
paste0("The deployments with the following deploymentID have missing ",
"`end` value: 29b7d356-4bb4-4ec4-b792-2af5cc32efa8, ",
"62c200a9-0e03-4495-bcd8-032944f6f5a1 and ",
"7ca633fa-64f8-4cfc-a628-6b0c419056d7.")
)
})

test_that("get_custom_effort returns error for invalid group_by value", {
expect_error(
get_custom_effort(mica, group_by = "bad_value"),
Expand Down

0 comments on commit 093979f

Please sign in to comment.