knitr::opts_chunk$set(
  error = TRUE,
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)
library(testthat)
library(jeksterslabRutils)
context("Test util_url_exists.")

Parameters

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
)

Run test

not_exist <- util_url_exists(con = wrong_url)
exist <- util_url_exists(con = correct_url)

Results

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
  )
})


jeksterslabds/jeksterslabRutils documentation built on Jan. 18, 2021, 11:41 p.m.