Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inkrement committed Jan 20, 2018
1 parent f59824d commit 9ad3609
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion tests/testthat/test-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ test_that("correct loading of and merging of different parameter sources", {
DEFAULT_PARAMS <- c(host='localhost', port=9000, db='default', user='default', password='', compression='lz4')
input_params <- c(host='customhost', db='input-db')
default_input_diff <- c(input_params[!(input_params %in% DEFAULT_PARAMS)])
config <- loadConfig(CONFIG_PATHS, DEFAULT_PARAMS, default_input_diff)

expect_warning({
config <- loadConfig(CONFIG_PATHS, DEFAULT_PARAMS, default_input_diff)
})

expect_equal(config, c(host='customhost', db='input-db', port=6666, user='default', password='', compression='lz4'))
})
15 changes: 8 additions & 7 deletions tests/testthat/utils.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@

# basic set-if-unset operator
"%||=%" <- function(x, y){
Var <- deparse(substitute(x))
if (!exists(Var))
assign(Var, y, parent.frame())
Var <- deparse(substitute(x))
if (!exists(Var))
assign(Var, y, parent.frame())
}

# set variables if not set yet
serveraddr %||=% "127.0.0.1"
user %||=% "default"
password %||=% ""
tblname %||=% "test"

getRealConnection <- function(){
# set variables if not set yet
serveraddr %||=% "localhost"
user %||=% "default"
password %||=% ''

# TODO: recycle connection by using singleton?
conn <- dbConnect(RClickhouse::clickhouse(), host=serveraddr, user=user, password=password)
return (conn)
Expand Down

0 comments on commit 9ad3609

Please sign in to comment.