testthat::setup({
url = 'https://www.football-data.co.uk/mmz4281/1920/E0.csv'
dummy_input <- read_csv('../testdata/dummy_input.csv')
ds_dummy_output <- read_csv('../testdata/do_something_dummy_output.csv')
dd_dummy_output <- read_csv('../testdata/download_data_dummy_output.csv')
url_data <- read_csv(url)
expected_columns <- c("Date", "HomeTeam", "AwayTeam", "FTHG", "FTAG")
})
# UNIT TESTS
## Test that do_something() works correctly on dummy data
test_that("do_something() returns expected output", {
expect_equal(ds_dummy_output, do_something(dummy_input))
})
## Test that the url exists
test_that("url exists", {
expect_true(url.exists(url))
})
# INTEGRATION TEST
## Test that the download data function works completely
test_that("download_data returns expected output", {
expect_equal(dd_dummy_output, download_data(url))
})
# TEST THE URL/DATA
# Test that the columns used in the project still exist
test_that("url columns exist", {
expect_true(min(expected_columns %in% names(url_data)) == TRUE)
})
# Test that the FTHG column is numeric
test_that("FTHG is numeric", {
expect_true(is.numeric(url_data$FTHG))
})
# Test that the FTAG column is numeric
test_that("FTAG is numeric", {
expect_true(is.numeric(url_data$FTAG))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.