Documentation ¶
Index ¶
- Variables
- func LoadFixtureFiles(db *sql.DB, h DataBaseHelper, files ...string) error
- func LoadFixtures(foldername string, db *sql.DB, h DataBaseHelper) error
- func ResetSequencesTo(value int64)
- func SkipDatabaseNameCheck(value bool)
- type DataBaseHelper
- type MySQLHelper
- type OracleHelper
- type PostgreSQLHelper
- type SQLServerHelper
- type SQLiteHelper
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWrongCastNotAMap is returned when a map is not a map[interface{}]interface{} ErrWrongCastNotAMap = fmt.Errorf("Could not cast record: not a map[interface{}]interface{}") // ErrFileIsNotSliceOrMap is returned the the fixture file is not a slice or map. ErrFileIsNotSliceOrMap = fmt.Errorf("The fixture file is not a slice or map") // ErrKeyIsNotString is returned when a record is not of type string ErrKeyIsNotString = fmt.Errorf("Record map key is not string") )
Functions ¶
func LoadFixtureFiles ¶ added in v1.6.0
func LoadFixtureFiles(db *sql.DB, h DataBaseHelper, files ...string) error
LoadFixtureFiles load all specified fixtures files into database:
LoadFixtureFiles(db, &PostgreSQLHelper{}, "fixtures/customers.yml", "fixtures/orders.yml") // add as many files you want
func LoadFixtures ¶
func LoadFixtures(foldername string, db *sql.DB, h DataBaseHelper) error
LoadFixtures loads all fixtures in a given folder into the database:
LoadFixtures("myfixturesfolder", db, &PostgreSQLHelper{})
func ResetSequencesTo ¶ added in v1.5.0
func ResetSequencesTo(value int64)
ResetSequencesTo sets the value the sequences will be reset to. This is used by PostgreSQL and Oracle. Defaults to 10000.
func SkipDatabaseNameCheck ¶ added in v1.3.2
func SkipDatabaseNameCheck(value bool)
SkipDatabaseNameCheck If true, loading fixtures will not check if the database name constaint "test". Use with caution!
Types ¶
type DataBaseHelper ¶
type DataBaseHelper interface {
// contains filtered or unexported methods
}
DataBaseHelper is the generic interface for the database helper
type MySQLHelper ¶ added in v1.1.0
type MySQLHelper struct{}
MySQLHelper is the MySQL helper for this package
type OracleHelper ¶ added in v1.5.0
type OracleHelper struct{}
OracleHelper is the Oracle database helper for this package
type PostgreSQLHelper ¶
type PostgreSQLHelper struct { // UseAlterConstraint If true, the contraint disabling will do // using ALTER CONTRAINT sintax, only allowed in PG >= 9.4. // If false, the constraint disabling will use DISABLE TRIGGER ALL, // which requires SUPERUSER privileges. UseAlterConstraint bool }
PostgreSQLHelper is the PG helper for this package
type SQLServerHelper ¶ added in v1.4.0
type SQLServerHelper struct{}
SQLServerHelper is the helper for SQL Server for this package. SQL Server >= 2008 is required.
type SQLiteHelper ¶ added in v1.3.0
type SQLiteHelper struct{}
SQLiteHelper is the SQLite Helper for this package