Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 1 | test_that("KorAPConnection is printable", { |
| 2 | kco <- new("KorAPConnection") |
| 3 | expect_error(print(kco), NA) |
| 4 | }) |
| 5 | |
Marc Kupietz | b2b32a3 | 2020-03-24 13:56:50 +0100 | [diff] [blame] | 6 | test_that("Opening KorAPConnection prints some message.", { |
| 7 | expect_message(new("KorAPConnection"), "KorAP") |
| 8 | }) |
| 9 | |
| 10 | test_that("Opening KorAPConnection with invalid apiToken fails", { |
| 11 | expect_error(new("KorAPConnection", accessToken="test token"), |
| 12 | "401") |
| 13 | }) |
| 14 | |
| 15 | test_that("Persisting null apiToken fails", { |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 16 | kco <- new("KorAPConnection") |
Marc Kupietz | 5a61f01 | 2021-03-04 18:25:27 +0100 | [diff] [blame] | 17 | skip_if_not(is.null(kco@accessToken)) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 18 | expect_error(persistAccessToken(kco), |
| 19 | ".*not supplied any access token.*", |
| 20 | perl = TRUE) |
| 21 | }) |
| 22 | |
| 23 | test_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 | }) |