Skip to content

Commit

Permalink
tests: add tests for ecb_euro_rates()
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Jul 27, 2024
1 parent deae867 commit bd4a805
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testthat/test-ecb-euro-rates.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("ecb_euro_rates works", {
skip_on_cran()
skip_on_ci()

expect_error(ecb_euro_rates("monthly"))
expect_error(ecb_euro_rates(NA))
expect_error(ecb_euro_rates(""))

x <- ecb_euro_rates("latest")
expect_named(x, c("date", "currency", "rate"))
expect_identical(dim(x), c(31L, 3L))
expect_s3_class(x, "data.frame")
expect_s3_class(x$date, "Date")
expect_vector(x$currency, character())
expect_vector(x$rate, double())

x <- ecb_euro_rates("history")
expect_named(x, c("date", "currency", "rate"))
expect_gt(nrow(x), 31L)
expect_s3_class(x, "data.frame")
expect_s3_class(x$date, "Date")
expect_vector(x$currency, character())
expect_vector(x$rate, double())
})

0 comments on commit bd4a805

Please sign in to comment.