how to create mock xorm.NewEngine("mysql", connStr) #1470

Open
opened 2019-10-28 17:31:14 +00:00 by myansenr · 2 comments

please help .. i have to create unit test

i need to make mock for this function ( connection mysql mock )

xorm.NewEngine("mysql", connStr)

can somebody help me ?

please help .. i have to create unit test i need to make mock for this function ( connection mysql mock ) xorm.NewEngine("mysql", connStr) can somebody help me ?
Owner

You can implement a mock core.Dialect, sql.driver implementations.

You can implement a mock `core.Dialect`, `sql.driver` implementations.
lunny added the
kind
enhancement
label 2019-10-29 00:17:20 +00:00
Author

can you give me some sample code ?

here is my code
// CONNECTION DB ENT APP
conn_db_mysql, err := xorm.NewEngine("mysql", connStr)
nc := 3 // Increase if needed. - number connection pooling
conn_db_mysql.SetMaxOpenConns(nc)
conn_db_mysql.SetMaxIdleConns(nc)
conn_db_mysql.SetConnMaxLifetime(time.Second * 3)
conn_db_mysql.SetMapper(core.GonicMapper{})
// db_ent_app.ShowSQL() // if want to show query to console

// SAVE TO GLOBAL STRUCT CONNECTION DB
db_sys = conn_db_mysql
can you give me some sample code ? here is my code // CONNECTION DB ENT APP conn_db_mysql, err := xorm.NewEngine("mysql", connStr) nc := 3 // Increase if needed. - number connection pooling conn_db_mysql.SetMaxOpenConns(nc) conn_db_mysql.SetMaxIdleConns(nc) conn_db_mysql.SetConnMaxLifetime(time.Second * 3) conn_db_mysql.SetMapper(core.GonicMapper{}) // db_ent_app.ShowSQL() // if want to show query to console // SAVE TO GLOBAL STRUCT CONNECTION DB db_sys = conn_db_mysql
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1470
No description provided.