2016-12-28 18:03:40 -07:00
|
|
|
package testfixtures
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2018-10-02 13:20:02 -06:00
|
|
|
// DataBaseHelper is the helper interface
|
|
|
|
// Deprecated: Use Helper instead
|
|
|
|
DataBaseHelper Helper
|
2016-12-28 18:03:40 -07:00
|
|
|
|
2018-10-02 13:20:02 -06:00
|
|
|
// PostgreSQLHelper is the PostgreSQL helper
|
|
|
|
// Deprecated: Use PostgreSQL{} instead
|
|
|
|
PostgreSQLHelper struct {
|
2016-12-28 18:03:40 -07:00
|
|
|
PostgreSQL
|
|
|
|
UseAlterConstraint bool
|
|
|
|
}
|
2018-10-02 13:20:02 -06:00
|
|
|
|
|
|
|
// MySQLHelper is the MySQL helper
|
|
|
|
// Deprecated: Use MySQL{} instead
|
|
|
|
MySQLHelper struct {
|
2016-12-28 18:03:40 -07:00
|
|
|
MySQL
|
|
|
|
}
|
2018-10-02 13:20:02 -06:00
|
|
|
|
|
|
|
// SQLiteHelper is the SQLite helper
|
|
|
|
// Deprecated: Use SQLite{} instead
|
|
|
|
SQLiteHelper struct {
|
2016-12-28 18:03:40 -07:00
|
|
|
SQLite
|
|
|
|
}
|
2018-10-02 13:20:02 -06:00
|
|
|
|
|
|
|
// SQLServerHelper is the SQLServer helper
|
|
|
|
// Deprecated: Use SQLServer{} instead
|
|
|
|
SQLServerHelper struct {
|
2016-12-28 18:03:40 -07:00
|
|
|
SQLServer
|
|
|
|
}
|
2018-10-02 13:20:02 -06:00
|
|
|
|
|
|
|
// OracleHelper is the Oracle helper
|
|
|
|
// Deprecated: Use Oracle{} instead
|
|
|
|
OracleHelper struct {
|
2016-12-28 18:03:40 -07:00
|
|
|
Oracle
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (h *PostgreSQLHelper) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) error {
|
|
|
|
h.PostgreSQL.UseAlterConstraint = h.UseAlterConstraint
|
|
|
|
return h.PostgreSQL.disableReferentialIntegrity(db, loadFn)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadFixtureFiles load all specified fixtures files into database:
|
|
|
|
// LoadFixtureFiles(db, &PostgreSQL{},
|
|
|
|
// "fixtures/customers.yml", "fixtures/orders.yml")
|
|
|
|
// // add as many files you want
|
|
|
|
//
|
|
|
|
// Deprecated: Use NewFiles() and Load() instead.
|
|
|
|
func LoadFixtureFiles(db *sql.DB, helper Helper, files ...string) error {
|
|
|
|
c, err := NewFiles(db, helper, files...)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Load()
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadFixtures loads all fixtures in a given folder into the database:
|
|
|
|
// LoadFixtures("myfixturesfolder", db, &PostgreSQL{})
|
|
|
|
//
|
|
|
|
// Deprecated: Use NewFolder() and Load() instead.
|
|
|
|
func LoadFixtures(folderName string, db *sql.DB, helper Helper) error {
|
|
|
|
c, err := NewFolder(db, helper, folderName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Load()
|
|
|
|
}
|