diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2017-12-24 01:33:34 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-24 02:33:34 +0200 |
commit | cc7b8e3379f46469d3ec72b044fb0f993fec4d1b (patch) | |
tree | 5086b854166f4134da1e0430e87f499e904594aa /models | |
parent | a995ad90e1055ad001a025a6d94fcc3d8ea87004 (diff) | |
download | gitea-cc7b8e3379f46469d3ec72b044fb0f993fec4d1b.tar.gz gitea-cc7b8e3379f46469d3ec72b044fb0f993fec4d1b.zip |
Add more bench (#3161)
* Improve makefile + Add benchs
* Apply recommendations of @ethantkoenig
Diffstat (limited to 'models')
-rw-r--r-- | models/unit_tests.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/models/unit_tests.go b/models/unit_tests.go index 25808a9486..8fdeb0b14b 100644 --- a/models/unit_tests.go +++ b/models/unit_tests.go @@ -115,7 +115,7 @@ func loadBeanIfExists(bean interface{}, conditions ...interface{}) (bool, error) } // BeanExists for testing, check if a bean exists -func BeanExists(t *testing.T, bean interface{}, conditions ...interface{}) bool { +func BeanExists(t testing.TB, bean interface{}, conditions ...interface{}) bool { exists, err := loadBeanIfExists(bean, conditions...) assert.NoError(t, err) return exists @@ -123,7 +123,7 @@ func BeanExists(t *testing.T, bean interface{}, conditions ...interface{}) bool // AssertExistsAndLoadBean assert that a bean exists and load it from the test // database -func AssertExistsAndLoadBean(t *testing.T, bean interface{}, conditions ...interface{}) interface{} { +func AssertExistsAndLoadBean(t testing.TB, bean interface{}, conditions ...interface{}) interface{} { exists, err := loadBeanIfExists(bean, conditions...) assert.NoError(t, err) assert.True(t, exists, @@ -133,7 +133,7 @@ func AssertExistsAndLoadBean(t *testing.T, bean interface{}, conditions ...inter } // GetCount get the count of a bean -func GetCount(t *testing.T, bean interface{}, conditions ...interface{}) int { +func GetCount(t testing.TB, bean interface{}, conditions ...interface{}) int { sess := x.NewSession() defer sess.Close() whereConditions(sess, conditions) @@ -143,7 +143,7 @@ func GetCount(t *testing.T, bean interface{}, conditions ...interface{}) int { } // AssertNotExistsBean assert that a bean does not exist in the test database -func AssertNotExistsBean(t *testing.T, bean interface{}, conditions ...interface{}) { +func AssertNotExistsBean(t testing.TB, bean interface{}, conditions ...interface{}) { exists, err := loadBeanIfExists(bean, conditions...) assert.NoError(t, err) assert.False(t, exists) @@ -158,18 +158,18 @@ func AssertExistsIf(t *testing.T, expected bool, bean interface{}, conditions .. } // AssertSuccessfulInsert assert that beans is successfully inserted -func AssertSuccessfulInsert(t *testing.T, beans ...interface{}) { +func AssertSuccessfulInsert(t testing.TB, beans ...interface{}) { _, err := x.Insert(beans...) assert.NoError(t, err) } // AssertCount assert the count of a bean -func AssertCount(t *testing.T, bean interface{}, expected interface{}) { +func AssertCount(t testing.TB, bean interface{}, expected interface{}) { assert.EqualValues(t, expected, GetCount(t, bean)) } // AssertInt64InRange assert value is in range [low, high] -func AssertInt64InRange(t *testing.T, low, high, value int64) { +func AssertInt64InRange(t testing.TB, low, high, value int64) { assert.True(t, value >= low && value <= high, "Expected value in range [%d, %d], found %d", low, high, value) } |