diff --git a/R/get_pipeline_report.R b/R/get_pipeline_report.R index eebb60d..d1439f9 100644 --- a/R/get_pipeline_report.R +++ b/R/get_pipeline_report.R @@ -21,7 +21,8 @@ get_pipeline_report <- function(user_code, api_token, pipelineid) { warning("Please add a valid API token") } else if (missing(pipelineid)) { warning("Please add a valid pipeline ID") - } else + } else { + tryCatch( { r <- get_request(user_code = user_code, @@ -68,5 +69,6 @@ get_pipeline_report <- function(user_code, api_token, pipelineid) { -result_website, -result_contact_custom_fields) return(contenido) + } } diff --git a/tests/testthat/test-error-warning-msg.R b/tests/testthat/test-error-warning-msg.R new file mode 100644 index 0000000..40ffd03 --- /dev/null +++ b/tests/testthat/test-error-warning-msg.R @@ -0,0 +1,24 @@ +context("Error and warning messages") + +testthat::test_that("Invalid credentials", { + expect_warning( + get_pipeline_report(api_token = "96066", + pipelineid = "57102821"), + "Please add a valid user code" + ) + + expect_warning( + get_pipeline_report(user_code = "6A6E88", + pipelineid = "57102821"), + "Please add a valid API token" + ) + + expect_warning( + get_pipeline_report(user_code = "6A6E88", + api_token = "96066"), + "Please add a valid pipeline ID" + ) +}) + + +