blob: 65c8f82c0831165dd39f5efcfab70a7d51acd25d [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")
17 expect_null(kco@accessToken)
18 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})