vignettes/tests/test_util_url_exists.Rmd
test_util_url_exists.Rmd
library(testthat)
library(jeksterslabRutils)
context("Test util_url_exists.")
wrong_url <- "https://thisWebsiteDoesNotExist123.com"
wrong_url_expected <- FALSE
correct_url <- "https://www.google.com"
correct_url_expected <- TRUE
Variable <- c(
"`wrong_url`",
"`correct_url`"
)
Description <- c(
paste0("Wrong URL (", wrong_url, ")."),
paste0("Correct URL (", correct_url, ").")
)
Value <- c(
wrong_url_expected,
correct_url_expected
)
knitr::kable(
x = data.frame(
Variable,
Description,
Value
),
row.names = FALSE
)
Variable | Description | Value |
---|---|---|
wrong_url |
Wrong URL (https://thisWebsiteDoesNotExist123.com). | FALSE |
correct_url |
Correct URL (https://www.google.com). | TRUE |
not_exist <- util_url_exists(con = wrong_url)
exist <- util_url_exists(con = correct_url)
Parameter <- c(
wrong_url_expected,
correct_url_expected
)
Result <- c(
not_exist,
exist
)
knitr::kable(
x = data.frame(
Description,
Parameter,
Result
),
row.names = FALSE
)
Description | Parameter | Result |
---|---|---|
Wrong URL (https://thisWebsiteDoesNotExist123.com). | FALSE | FALSE |
Correct URL (https://www.google.com). | TRUE | TRUE |
test_that("util_url_exists returns FALSE", {
expect_false(
not_exist
)
})
#> Test passed 🎊
test_that("util_url_exists returns TRUE", {
expect_true(
exist
)
})
#> Test passed 🥇