Running ‘testthat.R’ [3s/9s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(kiwisR)
  > 
  > test_check("kiwisR")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  kiwisR
   --- call from context --- 
  ki_station_list(hub = example_hub)
   --- call from argument --- 
  if (class(json_content) == "character") {
      return("No matches for search term.")
  }
   --- R stacktrace ---
  where 1 at testthat/test_ki_station_list.R#15: ki_station_list(hub = example_hub)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test_ki_station_list.R#11: test_that("ki_station_list should return a tibble", {
      skip_if_net_down()
      skip_if_exp_down()
      stns <- ki_station_list(hub = example_hub)
      expect_is(stns, c("tbl_df", "tbl", "data.frame"))
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 40: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: test_check("kiwisR")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (hub, search_term, bounding_box, group_id, return_fields) 
  {
      garbage <- c("^#", "^--", "testing", "^Template\\s", "\\sTEST$", 
          "\\sTEMP$", "\\stest\\s")
      if (missing(return_fields)) {
          return_fields <- "station_name,station_no,station_id,station_latitude,station_longitude"
      }
      else {
          if (!is.vector(return_fields) & !is.character(return_fields)) {
              stop("User supplied return_fields must be comma separate string or vector of fields.")
          }
      }
      api_url <- check_hub(hub)
      api_query <- list(service = "kisters", type = "queryServices", 
          request = "getStationList", format = "json", kvp = "true", 
          returnfields = paste(return_fields, collapse = ","))
      if (!missing(search_term)) {
          search_term <- paste(search_term, toupper(search_term), 
              tolower(search_term), sep = ",")
          api_query[["station_name"]] <- search_term
      }
      if (!missing(bounding_box)) {
          bounding_box <- paste(bounding_box, collapse = ",")
          api_query[["bbox"]] <- bounding_box
      }
      if (!missing(group_id)) {
          api_query[["stationgroup_id"]] <- group_id
      }
      raw <- tryCatch({
          httr::GET(url = api_url, query = api_query, httr::timeout(15))
      }, error = function(e) {
          return(e)
      })
      if (sum(grepl("error", class(raw)))) {
          stop("Query returned error: ", raw$message)
      }
      raw_content <- httr::content(raw)
      if (class(raw) != "response" | class(raw_content) != "list") {
          stop("Check that KiWIS hub is accessible via a web browser.")
      }
      json_content <- jsonlite::fromJSON(httr::content(raw, "text"))
      if (class(json_content) == "character") {
          return("No matches for search term.")
      }
      content_dat <- tibble::as_tibble(json_content, .name_repair = "minimal")[-1, 
          ]
      colnames(content_dat) <- json_content[1, ]
      if ("station_name" %in% names(content_dat)) {
          content_dat <- content_dat[!grepl(paste(garbage, collapse = "|"), 
              content_dat$station_name), ]
      }
      content_dat <- suppressWarnings(dplyr::mutate_at(content_dat, 
          dplyr::vars(dplyr::one_of(c("station_latitude", "station_longitude"))), 
          as.double))
      return(content_dat)
  }
  <bytecode: 0x55df2772cf80>
  <environment: namespace:kiwisR>
   --- function search by body ---
  Function ki_station_list in namespace kiwisR has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1