Skip to content

Commit

Permalink
add more tests for pick_spectra() to fix #26
Browse files Browse the repository at this point in the history
  • Loading branch information
cpauvert committed Oct 24, 2023
1 parent 17384eb commit 64c11bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dev/dereplicate-spectra.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,14 @@ test_that("pick_spectra works", {
pick_spectra(clusters, is_sorted = TRUE)$to_pick,
c(FALSE, FALSE, TRUE, FALSE, TRUE, FALSE)
)
expect_message(
out <- pick_spectra(clusters, metadata, "OD600", is_sorted = TRUE),
"The 'is_sorted' flag is set to TRUE, while a metadata table is provided."
)
expect_equal(
out$to_pick,
c(FALSE, TRUE, FALSE, TRUE, FALSE, FALSE)
)
})
test_that("pick_spectra fails without metadata and column", {
expect_error(
Expand All @@ -1412,6 +1420,16 @@ test_that("pick_spectra fails without metadata and column", {
pick_spectra(clusters, altered_metadata, "OD600"),
"The spectra names in the metadata"
)
expect_error(
pick_spectra(clusters, metadata, "CRITERIA_NOT_IN_TIBBLE"),
"The 'criteria_column' is not present in the merged tibble."
)
expect_error(
pick_spectra(clusters, metadata, "OD600",
soft_mask_column = "is_egde" # Typo in soft_mask_column
),
"The 'soft_mask_column' is not present in the merged tibble."
)
expect_error(
pick_spectra(clusters, metadata, "OD600",
hard_mask_column = "NOT_IN_TIBBLE"
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-pick_spectra.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ test_that("pick_spectra works", {
pick_spectra(clusters, is_sorted = TRUE)$to_pick,
c(FALSE, FALSE, TRUE, FALSE, TRUE, FALSE)
)
expect_message(
out <- pick_spectra(clusters, metadata, "OD600", is_sorted = TRUE),
"The 'is_sorted' flag is set to TRUE, while a metadata table is provided."
)
expect_equal(
out$to_pick,
c(FALSE, TRUE, FALSE, TRUE, FALSE, FALSE)
)
})
test_that("pick_spectra fails without metadata and column", {
expect_error(
Expand All @@ -63,6 +71,16 @@ test_that("pick_spectra fails without metadata and column", {
pick_spectra(clusters, altered_metadata, "OD600"),
"The spectra names in the metadata"
)
expect_error(
pick_spectra(clusters, metadata, "CRITERIA_NOT_IN_TIBBLE"),
"The 'criteria_column' is not present in the merged tibble."
)
expect_error(
pick_spectra(clusters, metadata, "OD600",
soft_mask_column = "is_egde" # Typo in soft_mask_column
),
"The 'soft_mask_column' is not present in the merged tibble."
)
expect_error(
pick_spectra(clusters, metadata, "OD600",
hard_mask_column = "NOT_IN_TIBBLE"
Expand Down

0 comments on commit 64c11bb

Please sign in to comment.