Skip to content

Commit

Permalink
Update test for fetch_distribution_history()
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Aug 2, 2024
1 parent 5312480 commit 32e41e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion R/fetch_distribution_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ fetch_distribution_history <- function(distributionID){

res <- qualtrics_api_request("GET", url = fetch_url)
elements <- append(elements, res$result$elements)
fetch_url <- res$result$nextPage
# check for "string" placeholder from mock server:
if (res$result$nextPage == "string") {
fetch_url <- NULL
} else {
fetch_url <- res$result$nextPage
}

}

Expand Down
12 changes: 5 additions & 7 deletions tests/testthat/test-fetch-distribution-history.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
test_that("fetch_distribution_history() returns a tbl_df with expected column names and types", {

skip_on_cran()

vcr::use_cassette("fetch_distribution_history", {
x <- fetch_distribution_history("EMD_RmjB8Gfpjlki6ms")
})
skip_on_cran()

test_that("fetch_distribution_history() returns a tbl_df with expected column names and types", {
local_mocked_bindings(glue_api_v3 = function(base_url) "https://stoplight.io/mocks/qualtricsv2/publicapidocs/60919")

x <- fetch_distribution_history("EMD_abcdef123456789")
expect_s3_class(x, c("tbl_df", "tbl", "data.frame"))
expect_s3_class(x$responseCompletedAt, c("POSIXct", "POSIXt"))
expect_s3_class(x$sentAt, c("POSIXct", "POSIXt"))
Expand Down

0 comments on commit 32e41e3

Please sign in to comment.