Skip to content

Commit

Permalink
update test to use with_mocked_bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
egeulgen committed Feb 15, 2025
1 parent 3d3f093 commit ac9eba4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/testthat/test-data_generation.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ test_that("`get_kegg_gsets()` -- works as expected", {
skip_on_cran()
mock_response <- "eco00010\tdescription\neco00071\tdescription2"

# function to manage sequential responses
mock_content <- function(...) {
return(mock_response)
}


with_mock(`httr::content` = mock_content, {
expect_is(toy_eco_kegg <- pathfindR:::get_kegg_gsets(), "list")
})
# mocked binding to manage sequential responses
with_mocked_bindings(
{
expect_is(toy_eco_kegg <- pathfindR:::get_kegg_gsets(), "list")
},
content = function(...) mock_response, .package = "httr"
)

expect_length(toy_eco_kegg, 2)
expect_true(all(names(toy_eco_kegg) == c("gene_sets", "descriptions")))
Expand Down

0 comments on commit ac9eba4

Please sign in to comment.