Less boilerplate in models/ unit tests (#725)

This commit is contained in:
Ethan Koenig 2017-01-24 21:49:51 -05:00 committed by Lunny Xiao
parent 75f0b0c51c
commit 8093b3372e
6 changed files with 47 additions and 113 deletions

View file

@ -59,10 +59,11 @@ func loadBeanIfExists(bean interface{}, conditions ...interface{}) (bool, error)
// AssertExistsAndLoadBean assert that a bean exists and load it from the test
// database
func AssertExistsAndLoadBean(t *testing.T, bean interface{}, conditions ...interface{}) {
func AssertExistsAndLoadBean(t *testing.T, bean interface{}, conditions ...interface{}) interface{} {
exists, err := loadBeanIfExists(bean, conditions...)
assert.NoError(t, err)
assert.True(t, exists)
return bean
}
// AssertNotExistsBean assert that a bean does not exist in the test database