1
0
Fork 0
forked from forgejo/forgejo

Move IssueUser code to separate file (#836)

Also add unit tests
This commit is contained in:
Ethan Koenig 2017-02-04 07:37:26 -05:00 committed by Lunny Xiao
parent d4035d1cb1
commit d0960b8035
6 changed files with 226 additions and 126 deletions

View file

@ -51,6 +51,7 @@ func CreateTestEngine() error {
if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil {
return err
}
fixtures, err = testfixtures.NewFolder(x.DB().DB, &testfixtures.SQLite{}, "fixtures/")
return err
}
@ -82,7 +83,8 @@ func BeanExists(t *testing.T, bean interface{}, conditions ...interface{}) bool
func AssertExistsAndLoadBean(t *testing.T, bean interface{}, conditions ...interface{}) interface{} {
exists, err := loadBeanIfExists(bean, conditions...)
assert.NoError(t, err)
assert.True(t, exists)
assert.True(t, exists,
"Expected to find %+v (with conditions %+v), but did not", bean, conditions)
return bean
}
@ -92,3 +94,15 @@ func AssertNotExistsBean(t *testing.T, bean interface{}, conditions ...interface
assert.NoError(t, err)
assert.False(t, exists)
}
// AssertSuccessfulInsert assert that beans is successfully inserted
func AssertSuccessfulInsert(t *testing.T, beans ...interface{}) {
_, err := x.Insert(beans...)
assert.NoError(t, err)
}
// AssertSuccessfulUpdate assert that bean is successfully updated
func AssertSuccessfulUpdate(t *testing.T, bean interface{}, conditions ...interface{}) {
_, err := x.Update(bean, conditions...)
assert.NoError(t, err)
}