github.com/kotovmak/go-admin@v1.1.1/modules/db/statement_mysql_test.go (about) 1 package db 2 3 import ( 4 "fmt" 5 "os/exec" 6 "testing" 7 8 _ "github.com/kotovmak/go-admin/modules/db/drivers/mysql" 9 ) 10 11 var driverTestMysqlConn Connection 12 13 const ( 14 driverTestDBName = "go-admin-statement-test" 15 ) 16 17 func InitMysql() { 18 c := testConnDSN(DriverMysql, fmt.Sprintf("root:root@tcp(127.0.0.1:3306)/%s", driverTestDBName)) 19 _, err := c.Exec(fmt.Sprintf("create database if not exists `%s`", driverTestDBName)) 20 if err != nil { 21 panic(err) 22 } 23 24 cmd := exec.Command("mysql", "-u", "root", "-proot", driverTestDBName, 25 "-e", "source "+testCurrentPath()+"/../../data/admin.sql") 26 err = cmd.Run() 27 if err != nil { 28 panic(err) 29 } 30 31 driverTestMysqlConn = testConnDSN(DriverMysql, fmt.Sprintf("root:root@tcp(127.0.0.1:3306)/%s", driverTestDBName)) 32 } 33 34 func TestMysqlSQL_WhereIn(t *testing.T) { testSQLWhereIn(t, driverTestMysqlConn) } 35 func TestMysqlSQL_Count(t *testing.T) { testSQLCount(t, driverTestMysqlConn) } 36 func TestMysqlSQL_Select(t *testing.T) { testSQLSelect(t, driverTestMysqlConn) } 37 func TestMysqlSQL_OrderBy(t *testing.T) { testSQLOrderBy(t, driverTestMysqlConn) } 38 func TestMysqlSQL_GroupBy(t *testing.T) { testSQLGroupBy(t, driverTestMysqlConn) } 39 func TestMysqlSQL_Skip(t *testing.T) { testSQLSkip(t, driverTestMysqlConn) } 40 func TestMysqlSQL_Take(t *testing.T) { testSQLTake(t, driverTestMysqlConn) } 41 func TestMysqlSQL_Where(t *testing.T) { testSQLWhere(t, driverTestMysqlConn) } 42 func TestMysqlSQL_WhereNotIn(t *testing.T) { testSQLWhereNotIn(t, driverTestMysqlConn) } 43 func TestMysqlSQL_Find(t *testing.T) { testSQLFind(t, driverTestMysqlConn) } 44 func TestMysqlSQL_Sum(t *testing.T) { testSQLSum(t, driverTestMysqlConn) } 45 func TestMysqlSQL_Max(t *testing.T) { testSQLMax(t, driverTestMysqlConn) } 46 func TestMysqlSQL_Min(t *testing.T) { testSQLMin(t, driverTestMysqlConn) } 47 func TestMysqlSQL_Avg(t *testing.T) { testSQLAvg(t, driverTestMysqlConn) } 48 func TestMysqlSQL_WhereRaw(t *testing.T) { testSQLWhereRaw(t, driverTestMysqlConn) } 49 func TestMysqlSQL_UpdateRaw(t *testing.T) { testSQLUpdateRaw(t, driverTestMysqlConn) } 50 func TestMysqlSQL_LeftJoin(t *testing.T) { testSQLLeftJoin(t, driverTestMysqlConn) } 51 func TestMysqlSQL_WithTransaction(t *testing.T) { testSQLWithTransaction(t, driverTestMysqlConn) } 52 func TestMysqlSQL_WithTransactionByLevel(t *testing.T) { 53 testSQLWithTransactionByLevel(t, driverTestMysqlConn) 54 } 55 func TestMysqlSQL_First(t *testing.T) { testSQLFirst(t, driverTestMysqlConn) } 56 func TestMysqlSQL_All(t *testing.T) { testSQLAll(t, driverTestMysqlConn) } 57 func TestMysqlSQL_ShowColumns(t *testing.T) { testSQLShowColumns(t, driverTestMysqlConn) } 58 func TestMysqlSQL_ShowTables(t *testing.T) { testSQLShowTables(t, driverTestMysqlConn) } 59 func TestMysqlSQL_Update(t *testing.T) { testSQLUpdate(t, driverTestMysqlConn) } 60 func TestMysqlSQL_Delete(t *testing.T) { testSQLDelete(t, driverTestMysqlConn) } 61 func TestMysqlSQL_Exec(t *testing.T) { testSQLExec(t, driverTestMysqlConn) } 62 func TestMysqlSQL_Insert(t *testing.T) { testSQLInsert(t, driverTestMysqlConn) } 63 func TestMysqlSQL_Wrap(t *testing.T) { testSQLWrap(t, driverTestMysqlConn) }