tests/testthat/test-view_datasets_sportsR.R

# sportsR - A Comprehensive Collection of Sports and Athletics Datasets
# Version 0.1.0
# Copyright (C) 2026 Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# view_datasets_sportsR

library(testthat)
library(sportsR)

test_that("view_datasets_sportsR works when package is loaded", {
  result <- view_datasets_sportsR()
  expect_type(result, "character")
  expect_true(length(result) > 0)
})

test_that("view_datasets_sportsR prints correct message", {
  output <- capture_messages(view_datasets_sportsR())
  expect_match(
    output[1],
    "Datasets available in the 'sportsR' package:",
    fixed = TRUE
  )
})

test_that("view_datasets_sportsR returns expected datasets", {
  datasets <- view_datasets_sportsR()
  expected_datasets <- c(
    "atp_matches_2019",
    "english_football",
    "italian_football",
    "mlb_teams_2019",
    "mlb_teams_2024",
    "pga_results",
    "warriors_2016",
    "warriors_2019",
    "wta_matches_2019"

  )
  # Check if all expected datasets are present
  missing_datasets <- setdiff(expected_datasets, datasets)
  expect_true(
    length(missing_datasets) == 0,
    info = paste("Missing datasets:", paste(missing_datasets, collapse = ", "))
  )
})

Try the sportsR package in your browser

Any scripts or data that you put into this service are public.

sportsR documentation built on Aug. 27, 2026, 1:08 a.m.