From 2b6ba63a55011c1a6f7885160c2dd3b92270f3ef Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 7 Jun 2020 18:08:31 +0300 Subject: [PATCH] ci: fix tests (most CI jobs do not have pg set up) --- vlib/orm/orm_test.v | 13 +++++++++---- vlib/pg/pg.v | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index 5f78cab702..25233f7b1f 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -1,4 +1,6 @@ +import os import pg +import term struct Modules { id int @@ -9,10 +11,13 @@ struct Modules { } fn test_orm() { - db := pg.connect( - dbname:'vpm' - user:'alex' - ) or { panic(err) } + dbname := os.getenv('VDB_NAME') + dbuser := os.getenv('VDB_USER') + if dbname == '' || dbuser == '' { + eprintln(term.red('NB: this test requires VDB_NAME and VDB_USER env variables to be set')) + return + } + db := pg.connect(dbname: dbname, user: dbuser) or { panic(err) } /* //nr_modules := db.select count from modules //nr_modules := db.select count from Modules where id == 1 diff --git a/vlib/pg/pg.v b/vlib/pg/pg.v index ec9344d079..cbac7269e9 100644 --- a/vlib/pg/pg.v +++ b/vlib/pg/pg.v @@ -128,7 +128,6 @@ pub fn (db DB) exec_one(query string) ?Row { // free. This prevents warnings and doesn't seem to affect behavior. pub fn (db DB) exec_param_many(query string, params []string) []Row { unsafe { - b := sizeof(byteptr) mut param_vals := &byteptr(malloc(params.len * 8)) for i in 0..params.len { param_vals[i] = params[i].str