Skip to content
This repository was archived by the owner on Mar 25, 2019. It is now read-only.

Commit 8a5e3c1

Browse files
committed
Tests for otp_connect()
1 parent 7c53f18 commit 8a5e3c1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/testthat/test-otp_connect.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,30 @@
22

33
context("Test the otp_connect function")
44

5+
test_that("default object is created and make_url method works", {
6+
otpcon <- otp_connect(check = FALSE)
7+
expect_is(otpcon, "otpconnect")
8+
expect_match(make_url(otpcon), "http://localhost:8080/otp/routers/default")
9+
})
10+
11+
# the following tests require an OTP instance at http://localhost:8080/otp with "default" router
12+
13+
test_that("object returned when check is TRUE and router exists", {
14+
otpcon <- otp_connect()
15+
expect_is(otpcon, "otpconnect")
16+
})
17+
18+
test_that("correct message when check is TRUE and router exists", {
19+
expect_message(otp_connect(), "Router http://localhost:8080/otp/routers/default exists")
20+
})
21+
22+
23+
test_that("object is not returned when check is TRUE and router does not exist", {
24+
#otpcon <- otp_connect(router = "test")
25+
expect_false(exists("otpcon"))
26+
})
27+
28+
test_that("correct error when check is TRUE and router does not exist", {
29+
expect_error(otp_connect(router = "test"), "Router http://localhost:8080/otp/routers/test does not exist")
30+
})
31+

0 commit comments

Comments
 (0)