Skip to content

Commit

Permalink
avoid google in checking connection
Browse files Browse the repository at this point in the history
  • Loading branch information
DomBennett committed Jan 7, 2019
1 parent e96d57c commit d36ce7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
@@ -1,3 +1,9 @@
# restez (in development)

## Bug fixes

* Check internet connection in mainland China

# restez 1.0.0

## Post-review version of `restez` released.
Expand Down
11 changes: 5 additions & 6 deletions R/biomartr-tools.R
Expand Up @@ -7,14 +7,13 @@
#' @family private
# originally connected.to.internet
check_connection <- function() {
if (is.character(RCurl::getURL("www.google.com"))) {
check_url <- "https://www.ncbi.nlm.nih.gov/"
if (RCurl::url.exists(check_url)) {
TRUE
} else {
stop(
"It seems that you are not connected to the internet.
Could you please check?",
call. = FALSE
)
msg <- paste0("Unable to connect to ", char(check_url),
"Are you connected to the internet?")
stop(msg, call. = FALSE)
}
}

Expand Down
9 changes: 7 additions & 2 deletions other/dev.R
@@ -1,12 +1,17 @@



# TODO:

problem_files <- c('gbinv17.seq', 'gbpln118.seq', 'gbpln12.seq')
restez_path_set('.')
for (problem_file in problem_files) {
file_download(problem_file)
}

db_create()

devtools::load_all('.')
restez_path_set('.')

db_delete(everything = TRUE)
restez_path_set('.')
db_download()
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-biomartr-tools.R
Expand Up @@ -6,11 +6,11 @@ library(testthat)
context('Testing \'biomartr-tools\'')
test_that('check_connection() works', {
with_mock(
`RCurl::getURL` = function(...) FALSE,
`RCurl::url.exists` = function(...) FALSE,
expect_error(restez:::check_connection())
)
with_mock(
`RCurl::getURL` = function(...) '',
`RCurl::url.exists` = function(...) TRUE,
expect_true(restez:::check_connection())
)
})
Expand Down

0 comments on commit d36ce7c

Please sign in to comment.