From 760587777c103732612850fe8fa3460ca1bc433a Mon Sep 17 00:00:00 2001 From: larnsce Date: Wed, 8 Jul 2026 11:53:23 +0200 Subject: [PATCH 1/2] ci: run R-CMD-check on dev pushes and pull requests Review PRs target dev, which the previous main-only trigger never checked. The unused master branch reference is removed. --- .github/workflows/R-CMD-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0f2fe08..c327414 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -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 From 92c0492f6dc069fa2d32e80844b3eb9d30259301 Mon Sep 17 00:00:00 2001 From: larnsce Date: Wed, 8 Jul 2026 11:54:25 +0200 Subject: [PATCH 2/2] test: add testthat suite asserting the data contract Structure, completeness, uniqueness, referential integrity, and value ranges for trips and trucks, so CI guards the guarantees established in the data review. --- DESCRIPTION | 4 +++- tests/testthat.R | 12 +++++++++++ tests/testthat/test-data.R | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-data.R diff --git a/DESCRIPTION b/DESCRIPTION index 841c666..37df1ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..5e43e9f --- /dev/null +++ b/tests/testthat.R @@ -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") diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R new file mode 100644 index 0000000..6c29114 --- /dev/null +++ b/tests/testthat/test-data.R @@ -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")) +})