Skip to content

Commit 7fb5074

Browse files
authored
fix test (#233)
* fix test * ah a few more to fix
1 parent 814275a commit 7fb5074

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

‎tests/testthat/test-historical-webservice.R‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ httptest2::with_mock_dir("fixtures", {
2121

2222

2323
test_that("ws_daily_flows is empty with a nearish date", {
24+
# using a fixed date that was empty on the date of fixture creation
2425
expect_error(ws_daily_flows(
2526
station_number = "08MF005",
26-
start_date = Sys.Date() - 2,
27-
end_date = Sys.Date()
27+
start_date = as.Date("2025-10-27"),
28+
end_date = as.Date("2025-10-29")
2829
), "No data exists for this station query during the period chosen")
2930
})
3031

@@ -46,10 +47,11 @@ httptest2::with_mock_dir("fixtures", {
4647

4748

4849
test_that("ws_daily_levels is empty with a nearish date", {
50+
# using a fixed date that was empty on the date of fixture creation
4951
expect_error(ws_daily_levels(
5052
station_number = "08MF005",
51-
start_date = Sys.Date() - 2,
52-
end_date = Sys.Date()
53+
start_date = as.Date("2025-10-27"),
54+
end_date = as.Date("2025-10-29")
5355
), "No data exists for this station query during the period chosen")
5456
})
5557
})

‎tests/testthat/test-realtime-webservice.R‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ httptest2::with_mock_dir("fixtures", {
66
ws_test <- realtime_ws(
77
station_number = "08MF005",
88
parameters = c(46), ## Water level
9-
start_date = Sys.Date() - 7,
10-
end_date = Sys.Date() - 7
9+
start_date = as.Date("2025-10-22"),
10+
end_date = as.Date("2025-10-22")
1111
)
1212

1313
expect_identical(
@@ -36,8 +36,8 @@ httptest2::with_mock_dir("fixtures", {
3636
output <- realtime_ws(
3737
station_number = "08MF005",
3838
parameters = 46,
39-
start_date = Sys.Date() - 8,
40-
end_date = Sys.Date() - 7
39+
start_date = as.Date("2025-10-21"),
40+
end_date = as.Date("2025-10-22")
4141
)
4242

4343
expect_s3_class(output, "tbl_df")
@@ -68,8 +68,8 @@ test_that("realtime_ws handles Date objects", {
6868
output <- realtime_ws(
6969
station_number = "08MF005",
7070
parameters = 46,
71-
start_date = Sys.Date() - 8,
72-
end_date = Sys.Date() - 7
71+
start_date = as.Date("2025-10-21"),
72+
end_date = as.Date("2025-10-22")
7373
)
7474

7575
expect_s3_class(output, "tbl_df")

‎tests/testthat/test-webservice-classes.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ httptest2::with_mock_dir("fixtures", {
166166
result <- realtime_ws(
167167
station_number = "08MF005",
168168
parameters = 46,
169-
start_date = Sys.Date() - 7,
170-
end_date = Sys.Date() - 7
169+
start_date = as.Date("2025-10-22"),
170+
end_date = as.Date("2025-10-22")
171171
)
172172

173173
expect_s3_class(result, "ws")

0 commit comments

Comments
 (0)