Documentation ¶
Index ¶
- Constants
- func AssertCount(t assert.TestingT, bean, expected interface{})
- func AssertCountByCond(t assert.TestingT, tableName string, cond builder.Cond, expected int)
- func AssertExistsAndLoadBean(t assert.TestingT, bean interface{}, conditions ...interface{}) interface{}
- func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...interface{}) map[string]string
- func AssertExistsIf(t assert.TestingT, expected bool, bean interface{}, conditions ...interface{})
- func AssertInt64InRange(t assert.TestingT, low, high, value int64)
- func AssertNotExistsBean(t assert.TestingT, bean interface{}, conditions ...interface{})
- func AssertSuccessfulInsert(t assert.TestingT, beans ...interface{})
- func BeanExists(t assert.TestingT, bean interface{}, conditions ...interface{}) bool
- func CheckConsistencyFor(t assert.TestingT, beansToCheck ...interface{})
- func Cond(query interface{}, args ...interface{}) interface{}
- func CreateTestEngine(opts FixturesOptions) error
- func FixturesDir() string
- func GetCount(t assert.TestingT, bean interface{}, conditions ...interface{}) int
- func GetCountByCond(t assert.TestingT, tableName string, cond builder.Cond) int64
- func GetXORMEngine(engine ...*xorm.Engine) (x *xorm.Engine)
- func InitFixtures(opts FixturesOptions, engine ...*xorm.Engine) (err error)
- func LoadBeanIfExists(bean interface{}, conditions ...interface{}) (bool, error)
- func LoadFixtures(engine ...*xorm.Engine) error
- func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string)
- func PrepareTestDatabase() error
- func PrepareTestEnv(t testing.TB)
- type FixturesOptions
Constants ¶
const NonexistentID = int64(math.MaxInt64)
NonexistentID an ID that will never exist
Variables ¶
This section is empty.
Functions ¶
func AssertCount ¶
AssertCount assert the count of a bean
func AssertCountByCond ¶
AssertCountByCond test the count of database entries matching bean
func AssertExistsAndLoadBean ¶
func AssertExistsAndLoadBean(t assert.TestingT, bean interface{}, conditions ...interface{}) interface{}
AssertExistsAndLoadBean assert that a bean exists and load it from the test database
func AssertExistsAndLoadMap ¶
func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...interface{}) map[string]string
AssertExistsAndLoadMap assert that a row exists and load it from the test database
func AssertExistsIf ¶
AssertExistsIf asserts that a bean exists or does not exist, depending on what is expected.
func AssertInt64InRange ¶
AssertInt64InRange assert value is in range [low, high]
func AssertNotExistsBean ¶
AssertNotExistsBean assert that a bean does not exist in the test database
func AssertSuccessfulInsert ¶
AssertSuccessfulInsert assert that beans is successfully inserted
func BeanExists ¶
BeanExists for testing, check if a bean exists
func CheckConsistencyFor ¶
CheckConsistencyFor test that all matching database entries are consistent
func Cond ¶
func Cond(query interface{}, args ...interface{}) interface{}
Cond create a condition with arguments for a test
func CreateTestEngine ¶
func CreateTestEngine(opts FixturesOptions) error
CreateTestEngine creates a memory database and loads the fixture data from fixturesDir
func GetCountByCond ¶
GetCountByCond get the count of database entries matching bean
func GetXORMEngine ¶
GetXORMEngine gets the XORM engine
func InitFixtures ¶
func InitFixtures(opts FixturesOptions, engine ...*xorm.Engine) (err error)
InitFixtures initialize test fixtures for a test database
func LoadBeanIfExists ¶
LoadBeanIfExists loads beans from fixture database if exist
func LoadFixtures ¶
LoadFixtures load fixtures for a test database
func MainTest ¶
MainTest a reusable TestMain(..) function for unit tests that need to use a test database. Creates the test database, and sets necessary settings.
func PrepareTestDatabase ¶
func PrepareTestDatabase() error
PrepareTestDatabase load test fixtures into test database
func PrepareTestEnv ¶
PrepareTestEnv prepares the environment for unit tests. Can only be called by tests that use the above MainTest(..) function.
Types ¶
type FixturesOptions ¶
FixturesOptions fixtures needs to be loaded options