summaryrefslogtreecommitdiffstats
path: root/models/setup_for_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-02-04 07:37:26 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-04 20:37:26 +0800
commitd0960b80354c0c8326063c8408d2274adb50dec1 (patch)
tree7c082f5d30bee7a526c42a33031981b247eb537e /models/setup_for_test.go
parentd4035d1cb143a758463f2e3ee9d037fd5dab72f9 (diff)
downloadgitea-d0960b80354c0c8326063c8408d2274adb50dec1.tar.gz
gitea-d0960b80354c0c8326063c8408d2274adb50dec1.zip
Move IssueUser code to separate file (#836)
Also add unit tests
Diffstat (limited to 'models/setup_for_test.go')
-rw-r--r--models/setup_for_test.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/models/setup_for_test.go b/models/setup_for_test.go
index fd5a180aec..651e36e822 100644
--- a/models/setup_for_test.go
+++ b/models/setup_for_test.go
@@ -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)
+}