From e63e745aeb0218b8ed0f899e62f240c94e33a02a Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Fri, 22 Feb 2019 09:25:18 +0100 Subject: [PATCH] Use interface DBClient for better testability --- mysql.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql.go b/mysql.go index 05ef2736..5804d4ab 100644 --- a/mysql.go +++ b/mysql.go @@ -14,11 +14,14 @@ import ( // Either a connection or a transaction type DbClient interface { Query(query string, args ...interface{}) (*sql.Rows, error) + Ping() error + BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) + Exec(query string, args ...interface{}) (sql.Result, error) } // Database wrapper including helper functions type DBWrapper struct { - Db *sql.DB + Db DbClient ConnectedAtomic *uint32 //uint32 to be able to use atomic operations ConnectionUpCondition *sync.Cond ConnectionLostCounter int