mirror of
https://github.com/go-gitea/gitea
synced 2025-09-28 03:28:13 +00:00
Unit tests for token and update models
This commit is contained in:
committed by
Kim "BKC" Carlbäcker
parent
c0904f1942
commit
de8b73dd92
45
vendor/gopkg.in/testfixtures.v2/mysql.go
generated
vendored
Normal file
45
vendor/gopkg.in/testfixtures.v2/mysql.go
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
package testfixtures
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MySQL is the MySQL helper for this package
|
||||
type MySQL struct {
|
||||
baseHelper
|
||||
}
|
||||
|
||||
func (*MySQL) paramType() int {
|
||||
return paramTypeQuestion
|
||||
}
|
||||
|
||||
func (*MySQL) quoteKeyword(str string) string {
|
||||
return fmt.Sprintf("`%s`", str)
|
||||
}
|
||||
|
||||
func (*MySQL) databaseName(db *sql.DB) (dbName string) {
|
||||
db.QueryRow("SELECT DATABASE()").Scan(&dbName)
|
||||
return
|
||||
}
|
||||
|
||||
func (h *MySQL) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) error {
|
||||
// re-enable after load
|
||||
defer db.Exec("SET FOREIGN_KEY_CHECKS = 1")
|
||||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = tx.Exec("SET FOREIGN_KEY_CHECKS = 0"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = loadFn(tx); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
}
|
Reference in New Issue
Block a user