Skip to content

Commit

Permalink
code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bczernecki committed May 17, 2022
1 parent 0dacd70 commit 26c555a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/test-meteo_noaa_co2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("meteo_noaa_hourly", {
co2 = meteo_noaa_co2()
expect_true(is.data.frame(co2))
expect_true(nrow(co2) > 700)
expect_true(ncol(co2) >= 7)
})
26 changes: 24 additions & 2 deletions tests/testthat/test-nearest_stations_imgw.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
test_that("nearest_stations_imgw", {
x = nearest_stations_imgw(
x = suppressWarnings(nearest_stations_imgw(
type = "meteo",
rank = "synop",
year = 2018,
add_map = TRUE,
point = NULL,
no_of_stations = 50
)
))
# added suppresswarnings as encoding may give extra warnings:
testthat::expect_true(nrow(x) <= 50)

# too many values provided for points
testthat::expect_error(suppressWarnings(nearest_stations_imgw(
type = "meteo",
rank = "synop",
year = 2010,
point = c(15, 50, 100),
add_map = FALSE
)
)
)

# too high values in lon/lat:
testthat::expect_error(nearest_stations_imgw(
type = "meteo",
rank = "synop",
year = 2010,
point = c(999, 999),
add_map = FALSE
)
)

})
8 changes: 7 additions & 1 deletion tests/testthat/test-stations_ogimet.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
test_that("stations_ogimet", {
x = suppressWarnings(stations_ogimet(country = "Australia", add_map = FALSE))
x = suppressWarnings(stations_ogimet(country = "Australia", add_map = TRUE))

testthat::expect_true(nrow(x) >= 100)
testthat::expect_equal(ncol(x), 5)

if (requireNamespace("maps", quietly = TRUE)) {
x = suppressWarnings(stations_ogimet(country = "Australia", add_map = TRUE))
}

expect_error(stations_ogimet(country = NULL, add_map = FALSE))
expect_error(stations_ogimet(date = NULL, add_map = FALSE))
})


8 changes: 8 additions & 0 deletions tests/testthat/test-test_url.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

test_that("test_url", {

expect_message(test_url(link = "https://httpbin.org/status/404",
output = output))

})

0 comments on commit 26c555a

Please sign in to comment.