Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, dev]
pull_request:
branches: [main, master]
branches: [main, dev]

name: R-CMD-check

Expand Down
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ Suggests:
rmarkdown,
leaflet,
ggplot2,
lubridate
lubridate,
testthat (>= 3.2.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/Needs/website: rmarkdown, leaflet, htmlwidgets, webshot2
Date: 2026-07-08
URL: https://github.com/openwashdata/fslogisticskampala
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(fslogisticskampala)

test_check("fslogisticskampala")
43 changes: 43 additions & 0 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
test_that("trips has the documented structure", {
expect_s3_class(trips, "data.frame")
expect_named(
trips,
c("fid", "numberplate", "date", "time", "lat", "lon", "plant")
)
expect_type(trips$fid, "integer")
expect_type(trips$numberplate, "character")
expect_s3_class(trips$date, "Date")
expect_s3_class(trips$time, "hms")
expect_type(trips$lat, "double")
expect_type(trips$lon, "double")
expect_type(trips$plant, "character")
})

test_that("trucks has the documented structure", {
expect_s3_class(trucks, "data.frame")
expect_named(trucks, c("numberplate", "volume"))
expect_type(trucks$numberplate, "character")
expect_type(trucks$volume, "double")
})

test_that("datasets are complete and identifiers are unique", {
expect_false(anyNA(trips))
expect_false(anyNA(trucks))
expect_false(anyDuplicated(trips$fid) > 0)
expect_false(anyDuplicated(trucks$numberplate) > 0)
})

test_that("every trip joins to a truck", {
expect_in(trips$numberplate, trucks$numberplate)
})

test_that("values are within plausible ranges", {
# Coordinates lie within Uganda; dates within the documented collection
# period; volumes within plausible vacuum truck sizes.
expect_true(all(trips$lat > -1.5 & trips$lat < 4.5))
expect_true(all(trips$lon > 29.5 & trips$lon < 35.5))
expect_true(all(trips$date >= as.Date("2015-03-30")))
expect_true(all(trips$date <= as.Date("2015-06-25")))
expect_true(all(trucks$volume >= 2 & trucks$volume <= 12))
expect_setequal(unique(trips$plant), c("Bugolobi", "Lubigi"))
})
Loading