Running ‘testthat.R’ [1s/402s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(kofdata)
  Loading required package: jsonlite
  Loading required package: httr
  > 
  > test_check("kofdata")
  ── 1. Failure: get_dataset works (@test_get_dataset.R#4)  ──────────────────────
  `get_dataset("some_nonexistent_set")` threw an error with unexpected message.
  Expected match: "The API responded"
  Actual message: "lexical error: invalid char in json text.\n                                       <html>  <head><title>502 Bad Ga\n                     (right here) ------^\n"
  
  ── 2. Failure: get_dataset works (@test_get_dataset.R#5)  ──────────────────────
  `get_dataset("set_doesnt_matter", "GandalfTheGray")` threw an error with unexpected message.
  Expected match: "Could not authenticate."
  Actual message: "lexical error: invalid char in json text.\n                                       <html>  <head><title>502 Bad Ga\n                     (right here) ------^\n"
  
  ── 3. Error: get_dataset works (@test_get_dataset.R#7)  ────────────────────────
  lexical error: invalid char in json text.
                                         <html>  <head><title>502 Bad Ga
                       (right here) ------^
  1: get_dataset("baro_vintages_monthly") at testthat/test_get_dataset.R:7
  2: fromJSON(content(response, as = "text"))
  3: fromJSON_string(txt = txt, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, 
         simplifyMatrix = simplifyMatrix, flatten = flatten, ...)
  4: parseJSON(txt, bigint_as_char)
  5: parse_string(txt, bigint_as_char)
  
  ── 4. Error: get_metadata works (@test_get_metadata.R#4)  ──────────────────────
  lexical error: invalid char in json text.
                                         <html>  <head><title>502 Bad Ga
                       (right here) ------^
  1: expect_true(is.na(get_metadata("nokey"))) at testthat/test_get_metadata.R:4
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: get_metadata("nokey")
  5: lapply(ts_keys, function(key) {
         query$key = key
         response <- GET(url, query = query)
         data <- fromJSON(content(response, as = "text"))
         data[data == "NA"] <- NA
         if (!is.null(data$info)) {
             NA
         }
         else {
             data
         }
     })
  6: FUN(X[[i]], ...)
  7: fromJSON(content(response, as = "text"))
  8: fromJSON_string(txt = txt, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, 
         simplifyMatrix = simplifyMatrix, flatten = flatten, ...)
  9: parseJSON(txt, bigint_as_char)
  10: parse_string(txt, bigint_as_char)
  
  ── 5. Failure: get_time_series works (@test_get_time_series.R#4)  ──────────────
  `get_time_series("some_nonexistent_key", show_progress = F)` threw an error with unexpected message.
  Expected match: "The API responded"
  Actual message: "lexical error: invalid char in json text.\n                                       <html>  <head><title>502 Bad Ga\n                     (right here) ------^\n"
  
  ── 6. Failure: get_time_series works (@test_get_time_series.R#5)  ──────────────
  `get_time_series("key_doesnt_matter", "GandalfTheGray", show_progress = F)` threw an error with unexpected message.
  Expected match: "Could not authenticate."
  Actual message: "lexical error: invalid char in json text.\n                                       <html>  <head><title>502 Bad Ga\n                     (right here) ------^\n"
  
  ── 7. Error: get_time_series works (@test_get_time_series.R#7)  ────────────────
  The API responded with
  The following keys do not exist: [kofbarometer]!.
  Are you sure the requested series are ALL public?
  1: get_time_series("kofbarometer", show_progress = F) at testthat/test_get_time_series.R:7
  2: stop(sprintf("The API responded with\n%s.\nAre you sure the requested series are ALL %s?", 
         data$message, ifelse(is.null(api_key), "public", "non-public")))
  
  ── 8. Error: list_keys_in_set works (@test_list_keys.R#5)  ─────────────────────
  An error occurred when calling the api:
  Status: 502
  Content:<html>
  <head><title>502 Bad Gateway</title></head>
  <body bgcolor="white">
  <center><h1>502 Bad Gateway</h1></center>
  <hr><center>nginx/1.10.2</center>
  </body>
  </html>
  1: list_available_sets() at testthat/test_list_keys.R:5
  2: stop(sprintf("An error occurred when calling the api:\nStatus: %d\nContent:%s", response$status_code, 
         content(response, as = "text")))
  
  ── 9. Failure: list_public_keys works (@test_list_public_keys.R#7)  ────────────
  `sets` inherits from `NULL` not `character`.
  
  ── 10. Failure: list_available_sets works (@test_list_sets.R#7)  ───────────────
  `sets` inherits from `list` not `data.frame`.
  
  ── 11. Failure: list_available_sets works (@test_list_sets.R#8)  ───────────────
  ncol(sets) not equal to 3.
  target is NULL, current is numeric
  
  ── 12. Failure: list_available_sets works (@test_list_sets.R#9)  ───────────────
  names(sets) not equal to c("set_name", "set_description", "is_public").
  target is NULL, current is character
  
  ── 13. Error: list_available_sets works (@test_list_sets.R#11)  ────────────────
  argument is of length zero
  1: .handleSimpleError(function (e) 
     {
         handled <<- TRUE
         test_error <<- e
         options(expressions = expressions_opt_new)
         on.exit(options(expressions = expressions_opt), add = TRUE)
         e$expectation_calls <- frame_calls(11, 2)
         test_error <<- e
         register_expectation(e)
         e$handled <- TRUE
         test_error <<- e
     }, "argument is of length zero", quote(if (nrow(sets) > 0) {
         expect_is(sets[1, "set_name"], "character")
         expect_is(sets[1, "set_description"], "character")
         expect_is(sets[1, "is_public"], "logical")
     })) at testthat/test_list_sets.R:11
  2: eval(code, test_env)
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 1 SKIPPED: 0 FAILED: 13
  1. Failure: get_dataset works (@test_get_dataset.R#4) 
  2. Failure: get_dataset works (@test_get_dataset.R#5) 
  3. Error: get_dataset works (@test_get_dataset.R#7) 
  4. Error: get_metadata works (@test_get_metadata.R#4) 
  5. Failure: get_time_series works (@test_get_time_series.R#4) 
  6. Failure: get_time_series works (@test_get_time_series.R#5) 
  7. Error: get_time_series works (@test_get_time_series.R#7) 
  8. Error: list_keys_in_set works (@test_list_keys.R#5) 
  9. Failure: list_public_keys works (@test_list_public_keys.R#7) 
  1. ...
  
  Error: testthat unit tests failed
  Execution halted