Skip to content

Commit

Permalink
Merge pull request #119 from natverse/fix/partial-server-url
Browse files Browse the repository at this point in the history
Fix and test incomplete server url
  • Loading branch information
jefferis authored May 17, 2020
2 parents 058e307 + 23581dd commit 00fd38f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/conn.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ neuprint_connection <- function(server=NULL, token=NULL, dataset=NULL,
# Set a default server if none specified
neuprint_server <-
if(is.null(server)) unlist(getenvoroption("server")) else server
# Set a default server if none specified
pu=httr::parse_url(neuprint_server)
if(is.null(pu$scheme)) {
pu$scheme="https"
if(is.null(pu$hostname)) {
pu$hostname=pu$path
pu$path=NULL
}
neuprint_server=httr::build_url(pu)
warning("No URL scheme specified for your server! Assuming it should be:x\n",
neuprint_server,
"\nPlease specify the URL in full next time!")
}
# Set a default token if none specified
neuprint_token <- if(is.null(token)) unlist(getenvoroption("token")) else token
# collect any curl options defined as environment variables
config=neuprint_curl_options(config)
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-conn.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ skip_if(as.logical(Sys.getenv("SKIP_NP_SERVER_TESTS")))
test_that("neuprint_login works", {
expect_error(neuprint_login(server="https://neuprint.janelia.org", dataset='rhubarb'))
})

test_that("neuprint_connection works", {
expect_warning(expect_is(
neuprint_connection(server = "neuprint.janelia.org", dataset = 'rhubarb'),
"neuprint_connection"
),
regexp = "https://neuprint.janelia.org")
})

0 comments on commit 00fd38f

Please sign in to comment.