Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add as_curve_params test #215

Merged
merged 10 commits into from
Jul 30, 2024
6 changes: 4 additions & 2 deletions R/as_curve_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#' as_curve_params()
#'
#' print(curve_data)

as_curve_params <- function(data, antigen_isos = NULL) {
curve_data <-
data %>%
Expand All @@ -23,7 +22,10 @@ as_curve_params <- function(data, antigen_isos = NULL) {

# check if object is curve (with columns)
if (!all(is.element(curve_cols, curve_data %>% names()))) {
cli::cli_abort("Please provide curve data")
cli::cli_abort(
class = "not curve_params",
message = c("Please provide curve data.")
d-morrison marked this conversation as resolved.
Show resolved Hide resolved
)
}

# assign curve class
Expand Down
104 changes: 104 additions & 0 deletions tests/testthat/_snaps/as_curve_params.md
chrisorwa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# `as_curve_params()` produces expected results

WAoAAAACAAQEAQACAwAAAAMTAAAABwAAAw0AAABkAAAAAQAAAAIAAAADAAAABAAAAAUAAAAB
AAAAAgAAAAMAAAAEAAAABQAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAQAAAAIAAAADAAAABAAA
AAUAAAABAAAAAgAAAAMAAAAEAAAABQAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAQAAAAIAAAAD
AAAABAAAAAUAAAABAAAAAgAAAAMAAAAEAAAABQAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAQAA
AAIAAAADAAAABAAAAAUAAAABAAAAAgAAAAMAAAAEAAAABQAAAAEAAAACAAAAAwAAAAQAAAAF
AAAAAQAAAAIAAAADAAAABAAAAAUAAAABAAAAAgAAAAMAAAAEAAAABQAAAAEAAAACAAAAAwAA
AAQAAAAFAAAAAQAAAAIAAAADAAAABAAAAAUAAAABAAAA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mFtZQAABAIAAAABAAQACQAAAAlyb3cu
bmFtZXMAAAANAAAAAoAAAAD///+cAAAEAgAAAAEABAAJAAAABW5hbWVzAAAAEAAAAAcABAAJ
AAAAC2FudGlnZW5faXNvAAQACQAAAARpdGVyAAQACQAAAAJ5MAAEAAkAAAACeTEABAAJAAAA
AnQxAAQACQAAAAVhbHBoYQAEAAkAAAABcgAABAIAAAABAAQACQAAAAxhbnRpZ2VuX2lzb3MA
AAMNAAAABQAAAAEAAAACAAAAAwAAAAQAAAAFAAAEAgAAAf8AAAAQAAAABQAEAAkAAAAISGx5
RV9JZ0EABAAJAAAACEhseUVfSWdHAAQACQAAAAdMUFNfSWdBAAQACQAAAAdMUFNfSWdHAAQA
CQAAAAZWaV9JZ0cAAAQCAAAC/wAAABAAAAABAAQACQAAAAZmYWN0b3IAAAD+AAAA/g==

25 changes: 25 additions & 0 deletions tests/testthat/test-as_curve_params.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test_that("`as_curve_params()` produces an error when non-curve data is provided", {
library(magrittr)
expect_error(
object = curve_data <-
"https://osf.io/download//n6cp3/" %>% # pop data
readr::read_rds() %>%
as_curve_params(),
class = "not curve_params"
)
})


test_that("`as_curve_params()` produces expected results", {
library(dplyr)
test_data <- "https://osf.io/download/rtw5k/" %>% # curve data
chrisorwa marked this conversation as resolved.
Show resolved Hide resolved
readr::read_rds() %>%
slice_head(n = 100) %>%
as_curve_params()


expect_snapshot_value(
x = test_data,
style = "serialize"
)
})
Loading