Skip to content

Commit 6ebd83f

Browse files
authored
chore(tests): Remove mockery dependency from tests (#1009)
1 parent 802c6d5 commit 6ebd83f

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Suggests:
4141
geojsonsf,
4242
htmlwidgets,
4343
later,
44-
mockery (>= 0.4.2),
4544
ragg,
4645
rapidoc,
4746
readr,

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Added support for [Arrow IPC Streams](https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc) (@josiahparry #968)
44

5+
* Removed deprecated `mockery` package dependency. Tests now use native R closures for callback tracking. (#1009)
6+
57
# plumber 1.3.0
68

79
* The port many now be specified as an environment variable. User-provided ports must be between 1024 and 49151 (following [IANA guidelines](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml)) and may not be a known unsafe port. plumber will now throw an error if an invalid port is requested. (@shikokuchuo @gadenbuie #963)

tests/testthat/test-plumber-run.R

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,46 @@ test_that("`docs` does not not permanetly set pr information", {
4242
})
4343

4444
test_that("`swaggerCallback` does not not permanetly set pr information", {
45-
skip_if_not_installed("mockery", "0.4.2")
45+
call_count <- 0
46+
m <- function(url) {
47+
call_count <<- call_count + 1
48+
TRUE
49+
}
50+
51+
# Initialize call count
52+
m("init")
53+
expect_equal(call_count, 1)
4654

47-
m <- mockery::mock(TRUE, cycle = TRUE)
48-
m() # call once so that `length(m)` > 0 as `length(m)` represents the number of calls to `m`
4955
root <- pr() %>% pr_set_docs_callback(m)
56+
5057
# m not used
5158
with_interrupt({
52-
mockery::expect_called(m, 1)
59+
expect_equal(call_count, 1)
5360
root %>% pr_run(swaggerCallback = NULL)
54-
mockery::expect_called(m, 1)
61+
expect_equal(call_count, 1)
5562
})
63+
5664
# m not used
5765
with_interrupt({
58-
mockery::expect_called(m, 1)
66+
expect_equal(call_count, 1)
5967
root$run(swaggerCallback = NULL)
60-
mockery::expect_called(m, 1)
68+
expect_equal(call_count, 1)
6169
})
70+
6271
# m is used
6372
with_interrupt({
64-
mockery::expect_called(m, 1)
73+
expect_equal(call_count, 1)
6574
root %>% pr_run(quiet = FALSE)
66-
mockery::expect_called(m, 2)
75+
expect_equal(call_count, 2)
6776
})
6877
})
6978

7079
test_that("`swaggerCallback` can be set by option after the pr is created", {
71-
skip_if_not_installed("mockery", "0.4.2")
72-
73-
m <- mockery::mock(TRUE)
80+
call_count <- 0
81+
m <- function(url) {
82+
call_count <<- call_count + 1
83+
TRUE
84+
}
7485

7586
# must initialize before options are set for this test
7687
root <- pr()
@@ -84,12 +95,11 @@ test_that("`swaggerCallback` can be set by option after the pr is created", {
8495
# set option after init
8596
options_plumber(docs.callback = m)
8697
with_interrupt({
87-
mockery::expect_called(m, 0)
98+
expect_equal(call_count, 0)
8899
pr_run(root)
89100
})
90101
}
91102
)
92103
# m is used
93-
mockery::expect_called(m, 1)
94-
104+
expect_equal(call_count, 1)
95105
})

0 commit comments

Comments
 (0)