1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-29 09:31:11 -05:00
forgejo/vendor/gopkg.in/testfixtures.v2/helper.go

39 lines
743 B
Go
Raw Normal View History

2016-12-28 20:03:40 -05:00
package testfixtures
import (
"database/sql"
"fmt"
)
const (
paramTypeDollar = iota + 1
paramTypeQuestion
paramTypeColon
)
type loadFunction func(tx *sql.Tx) error
// Helper is the generic interface for the database helper
type Helper interface {
init(*sql.DB) error
disableReferentialIntegrity(*sql.DB, loadFunction) error
paramType() int
databaseName(*sql.DB) string
quoteKeyword(string) string
whileInsertOnTable(*sql.Tx, string, func() error) error
}
type baseHelper struct{}
func (*baseHelper) init(_ *sql.DB) error {
return nil
}
func (*baseHelper) quoteKeyword(str string) string {
return fmt.Sprintf(`"%s"`, str)
}
func (*baseHelper) whileInsertOnTable(_ *sql.Tx, _ string, fn func() error) error {
return fn()
}