Documentation ¶
Index ¶
- Variables
- func GenerateFixtures(db *sql.DB, helper Helper, dir string) error
- func GenerateFixturesForTables(db *sql.DB, tables []*TableInfo, helper Helper, dir string) error
- func LoadFixtureFiles(db *sql.DB, helper Helper, files ...string) errordeprecated
- func LoadFixtures(folderName string, db *sql.DB, helper Helper) errordeprecated
- func ResetSequencesTo(value int64)
- func SkipDatabaseNameCheck(value bool)
- type Context
- type DataBaseHelper
- type Helper
- type InsertError
- type MySQL
- type MySQLHelper
- type Oracle
- type OracleHelper
- type PostgreSQL
- type PostgreSQLHelper
- type SQLServer
- type SQLServerHelper
- type SQLite
- type SQLiteHelper
- type TableInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWrongCastNotAMap is returned when a map is not a map[interface{}]interface{} ErrWrongCastNotAMap = errors.New("Could not cast record: not a map[interface{}]interface{}") // ErrFileIsNotSliceOrMap is returned the the fixture file is not a slice or map. ErrFileIsNotSliceOrMap = errors.New("The fixture file is not a slice or map") // ErrKeyIsNotString is returned when a record is not of type string ErrKeyIsNotString = errors.New("Record map key is not string") // ErrNotTestDatabase is returned when the database name doesn't contains "test" ErrNotTestDatabase = errors.New(`Loading aborted because the database name does not contains "test"`) )
var ErrCouldNotConvertToTime = errors.New("Could not convert string to time")
ErrCouldNotConvertToTime is returns when a string is not a reconizable time format
Functions ¶
func GenerateFixtures ¶
GenerateFixtures generates fixtures for the current contents of a database, and saves them to the specified directory
func GenerateFixturesForTables ¶
GenerateFixturesForTables generates fixtures for the current contents of specified tables in a database, and saves them to the specified directory
func LoadFixtureFiles
deprecated
added in
v1.6.0
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 Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds the fixtures to be loaded in the database.
func NewFiles ¶
NewFiles creates a context for all specified fixtures files into database:
NewFiles(db, &PostgreSQL{}, "fixtures/customers.yml", "fixtures/orders.yml" // add as many files you want )
func NewFolder ¶
NewFolder creates a context for all fixtures in a given folder into the database:
NewFolder(db, &PostgreSQL{}, "my/fixtures/folder")
func (*Context) DetectTestDatabase ¶
DetectTestDatabase returns nil if databaseName matches regexp
if err := fixtures.DetectTestDatabase(); err != nil { log.Fatal(err) }
type DataBaseHelper ¶
type DataBaseHelper Helper
DataBaseHelper is the helper interface Deprecated: Use Helper instead
type Helper ¶
type Helper interface {
// contains filtered or unexported methods
}
Helper is the generic interface for the database helper
type InsertError ¶
InsertError will be returned if any error happens on database while inserting the record
func (*InsertError) Error ¶
func (e *InsertError) Error() string
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
MySQL is the MySQL helper for this package
type MySQLHelper ¶ added in v1.1.0
type MySQLHelper struct {
MySQL
}
MySQLHelper is the MySQL helper Deprecated: Use MySQL{} instead
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle is the Oracle database helper for this package
type OracleHelper ¶ added in v1.5.0
type OracleHelper struct {
Oracle
}
OracleHelper is the Oracle helper Deprecated: Use Oracle{} instead
type PostgreSQL ¶
type PostgreSQL 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 // SkipResetSequences prevents the reset of the databases // sequences after load fixtures time SkipResetSequences bool // contains filtered or unexported fields }
PostgreSQL is the PG helper for this package
type PostgreSQLHelper ¶
type PostgreSQLHelper struct { PostgreSQL UseAlterConstraint bool }
PostgreSQLHelper is the PostgreSQL helper Deprecated: Use PostgreSQL{} instead
type SQLServer ¶
type SQLServer struct {
// contains filtered or unexported fields
}
SQLServer is the helper for SQL Server for this package. SQL Server >= 2008 is required.
type SQLServerHelper ¶ added in v1.4.0
type SQLServerHelper struct {
SQLServer
}
SQLServerHelper is the SQLServer helper Deprecated: Use SQLServer{} instead
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
SQLite is the SQLite Helper for this package
type SQLiteHelper ¶ added in v1.3.0
type SQLiteHelper struct {
SQLite
}
SQLiteHelper is the SQLite helper Deprecated: Use SQLite{} instead