knitr::opts_chunk$set( error = TRUE, collapse = TRUE, comment = "#>", out.width = "100%" )
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 )
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 )
test_that("util_url_exists returns FALSE", { expect_false( not_exist ) })
test_that("util_url_exists returns TRUE", { expect_true( exist ) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.