Skip to content

Commit

Permalink
Update test codebase
Browse files Browse the repository at this point in the history
Fixes: 61ac560 ("Add SelectOne() to VizierDBInterface")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
  • Loading branch information
Koichiro Den committed Dec 5, 2018
1 parent d72d268 commit 25012d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/db/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

_ "github.com/go-sql-driver/mysql"
"github.com/golang/protobuf/jsonpb"
"gopkg.in/DATA-DOG/go-sqlmock.v1"

api "github.com/kubeflow/katib/pkg/api"
)
Expand All @@ -37,7 +38,10 @@ func TestMain(m *testing.M) {
os.Exit(1)
}
//mock.ExpectBegin()
dbInterface = NewWithSQLConn(db)
dbInterface, err = NewWithSQLConn(db)
if err != nil {
fmt.Printf("error NewWithSQLConn: %v\n", err)
}
mock.ExpectExec("CREATE TABLE IF NOT EXISTS studies").WithArgs().WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec("CREATE TABLE IF NOT EXISTS study_permissions").WithArgs().WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec("CREATE TABLE IF NOT EXISTS trials").WithArgs().WillReturnResult(sqlmock.NewResult(1, 1))
Expand All @@ -55,12 +59,17 @@ func TestMain(m *testing.M) {
mysqlAddr := os.Getenv("TEST_MYSQL")
if mysqlAddr != "" {
mysql, err := sql.Open("mysql", "root:test123@tcp("+mysqlAddr+")/vizier")

if err != nil {
fmt.Printf("error opening db: %v\n", err)
os.Exit(1)
}
mysqlInterface = NewWithSQLConn(mysql)

mysqlInterface, err = NewWithSQLConn(mysql)
if err != nil {
fmt.Printf("error initializing db interface: %v\n", err)
os.Exit(1)
}

mysqlInterface.DBInit()
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/mock/db/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25012d4

Please sign in to comment.