Skip tests that require internet if offline

Change-Id: I679362d9d3595c8212c20d2086d92afcbd58d13f
diff --git a/tests/testthat/test-corpusQuery.R b/tests/testthat/test-corpusQuery.R
index df512cd..0483745 100644
--- a/tests/testthat/test-corpusQuery.R
+++ b/tests/testthat/test-corpusQuery.R
@@ -1,10 +1,12 @@
 test_that("frequencyQuery can be cached", {
+  skip_if_offline()
   kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE)
   frequencyQuery(kco, "Ameisenplage", "pubDate since 2014")
   expect_output(frequencyQuery(kco, "Ameisenplage", "pubDate since 2014"), "cached")
 })
 
 test_that("collocationScoreQuery works", {
+  skip_if_offline()
   kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE)
   df <- collocationScoreQuery(kco,"Ameisenplage", "heimgesucht", leftContextSize=0, rightContextSize=1)
   expect_gt(df$logDice, 1)
@@ -16,6 +18,7 @@
 })
 
 test_that("Cache depends on indexRevision (handling also NULL values)", {
+  skip_if_offline()
   kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE)
   kco@indexRevision <- NULL
   frequencyQuery(kco, "Ameisenplage", "pubDate since 2014")
@@ -25,6 +28,7 @@
 })
 
 test_that("corpusQuery returns results", {
+  skip_if_offline()
   q <- new("KorAPConnection") %>%
     corpusQuery("Ameisenplage")
   expect_gt(q@totalResults, 0)
@@ -36,6 +40,7 @@
   vc <- "pubPlace=N\xfcrnberg"
   Encoding(vc)="latin1"
 
+  skip_if_offline()
   q <- new("KorAPConnection") %>%
     corpusQuery(query, vc=vc)
   expect_gt(q@totalResults, 0)
@@ -47,12 +52,14 @@
   vc <- "pubPlace=N\xc3\xbcrnberg"
   Encoding(vc)="UTF-8"
 
+  skip_if_offline()
   q <- new("KorAPConnection") %>%
     corpusQuery(query, vc=vc)
   expect_gt(q@totalResults, 0)
 })
 
 test_that("fetchAll fetches all results", {
+  skip_if_offline()
   q <- new("KorAPConnection", verbose = TRUE) %>%
     corpusQuery("Ameisenplage", vc = "pubDate since 2014")
   expectedResults <- q@totalResults
@@ -61,11 +68,13 @@
 })
 
 test_that("Uncached query for non-matching search string return 0 results", {
+  skip_if_offline()
   q <- new("KorAPConnection", cache = FALSE) %>% corpusQuery("Xmeisenplagx")
   expect_equal( q@totalResults, 0)
 })
 
 test_that("Empty query result is printable", {
+  skip_if_offline()
   q <- new("KorAPConnection", cache = TRUE, verbose = TRUE) %>%
     corpusQuery("Xmeisenplagx", vc = "pubDate in 2012") %>%
     fetchNext()
@@ -73,6 +82,7 @@
 })
 
 test_that("Non-empty query result is printable", {
+  skip_if_offline()
   q <- new("KorAPConnection", cache = TRUE, verbose = TRUE) %>%
     corpusQuery("Ameisenplage", "pubDate since 2014", fields=c("sigle")) %>%
     fetchRest()
@@ -80,6 +90,7 @@
 })
 
 test_that("Query from KorAP URL returns as many results as corresponding direct query", {
+  skip_if_offline()
   kco <- new("KorAPConnection")
   r1 <- corpusQuery(kco, KorAPUrl = "https://korap.ids-mannheim.de/?q=Ameisenplage&cq=pubDate+since+2014&ql=poliqarp")@totalResults
   r2 <- corpusQuery(kco, "Ameisenplage", "pubDate since 2014")@totalResults
@@ -87,6 +98,7 @@
 })
 
 test_that("Typo in query causes error", {
+  skip_if_offline()
   kco <- new("KorAPConnection", verbose = TRUE)
-  expect_error(kco %>% corpusQuery("[[xx"), "unbalanced")
+  expect_message(kco %>% corpusQuery("[[xx"), "unbalanced")
 })