Skip to content

Commit

Permalink
lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisorwa committed Sep 5, 2024
1 parent 4259a77 commit 8379cef
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 166 deletions.
14 changes: 8 additions & 6 deletions R/as_noise_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ as_noise_params <- function(data, antigen_isos = NULL) {
class = "not data.frame",
message = c(
"Can't convert {.arg data} to {.cls noise_params}.",
"x" = "{.arg data} must be a {.cls data.frame}" %>%
"(or a subclass of {.cls data.frame}).",
paste("x" = "{.arg data} must be a {.cls data.frame}",
"(or a subclass of {.cls data.frame})."
),
"i" = "You have supplied a {.cls {class(data)}}."
)
)

Check warning on line 30 in R/as_noise_params.R

View check run for this annotation

Codecov / codecov/patch

R/as_noise_params.R#L21-L30

Added lines #L21 - L30 were not covered by tests
Expand All @@ -42,8 +43,9 @@ as_noise_params <- function(data, antigen_isos = NULL) {
class = "not noise_params",
message = c(
"Can't convert {.arg data} to {.cls noise_params}.",
"i" = "The column{?s} : {.strong {.var {missing_cols}}}" %>%
"{?is/are} missing.",
"i" = paste("The column{?s} : {.strong {.var {missing_cols}}}",
"{?is/are} missing."
),
"x" = "You have supplied {.cls {class(data)}}."
)
)
Expand All @@ -63,8 +65,8 @@ as_noise_params <- function(data, antigen_isos = NULL) {
class = "missing-antigen",
message = c(
"x" = "Can't convert {.var data} to {.cls noise_params}.",
"i" = "The antigen type{?s} {.str {missing_antigen}}" %>%
"{?is/are} missing in {.var data}."
"i" = paste("The antigen type{?s} {.str {missing_antigen}}",
"{?is/are} missing in {.var data}.")
)
)
}
Expand Down
4 changes: 0 additions & 4 deletions check.lintr

This file was deleted.

10 changes: 6 additions & 4 deletions man/as_curve_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions man/est.incidence.by.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/stratify_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 0 additions & 124 deletions tests/testthat/_snaps/as_curve_params.md

This file was deleted.

38 changes: 21 additions & 17 deletions tests/testthat/test-as_noise_params.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
test_that("`as_noise_params()` produces an error when non-noise data is provided", {
library(magrittr)
expect_error(
object = noise_data <-
"https://osf.io/download//n6cp3/" %>% # pop data
readr::read_rds() %>%
as_noise_params(),
class = "not noise_params"
)
})
test_that("`as_noise_params()` produces an error
when non-noise data is provided", {
library(magrittr)
expect_error(
object = noise_data <-
"https://osf.io/download//n6cp3/" %>% # pop data
readr::read_rds() %>%
as_noise_params(),
class = "not noise_params"
)
})

test_that("`as_noise_params()` produces expected results", {
library(dplyr)
Expand All @@ -23,11 +24,14 @@ test_that("`as_noise_params()` produces expected results", {
)
})

test_that("`as_noise_params()` produces error when wrong antigen_iso is provided", {
library(dplyr)
test_that("`as_noise_params()` produces error when
wrong antigen_iso is provided", {
library(dplyr)

expect_error(object = "https://osf.io/download//hqy4v/" %>% # noise data
readr::read_rds() %>%
as_noise_params(antigen_iso = "HlyE_IgB"),
class = 'missing-antigen')
})
expect_error(
object = "https://osf.io/download//hqy4v/" %>% # noise data
readr::read_rds() %>%
as_noise_params(antigen_iso = "HlyE_IgB"),
class = "missing-antigen"
)
})

0 comments on commit 8379cef

Please sign in to comment.