blob: c96805db97db5c71660921cc7ba6ae816c37efa1 [file] [log] [blame]
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01001test_that("KorAPConnection is printable", {
2 kco <- new("KorAPConnection")
3 expect_error(print(kco), NA)
4})
5
Marc Kupietzb2b32a32020-03-24 13:56:50 +01006test_that("Opening KorAPConnection prints some message.", {
7 expect_message(new("KorAPConnection"), "KorAP")
8})
9
10test_that("Opening KorAPConnection with invalid apiToken fails", {
11 expect_error(new("KorAPConnection", accessToken="test token"),
12 "401")
13})
14
15test_that("Persisting null apiToken fails", {
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010016 kco <- new("KorAPConnection")
Marc Kupietz5a61f012021-03-04 18:25:27 +010017 skip_if_not(is.null(kco@accessToken))
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010018 expect_error(persistAccessToken(kco),
19 ".*not supplied any access token.*",
20 perl = TRUE)
21})
22
23test_that("Opening KorAPConnection with KorAPUrl works", {
24 kco <- new("KorAPConnection", KorAPUrl="https://korap.ids-mannheim.de")
25 expect_equal(kco@apiUrl, paste0("https://korap.ids-mannheim.de/api/", kco@apiVersion, "/"))
26 kco <- new("KorAPConnection", KorAPUrl="https://korap.ids-mannheim.de/")
27 expect_equal(kco@apiUrl, paste0("https://korap.ids-mannheim.de/api/", kco@apiVersion, "/"))
28})