improved tests

This commit is contained in:
kolaente 2018-07-26 10:49:17 +02:00
parent a78b333e3f
commit 6eeab7fe10
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,5 @@
-
id: 1
name: testnamespace
description: Lorem Ipsum
owner_id: 1

View file

@ -17,8 +17,12 @@ func TestList_Create(t *testing.T) {
dummylist := List{
Title: "test",
Description: "Lorem Ipsum",
NamespaceID: 1,
}
// Check if the user can create
assert.True(t, dummylist.CanCreate(&doer))
// Create it
err = dummylist.Create(&doer)
assert.NoError(t, err)
@ -31,9 +35,30 @@ func TestList_Create(t *testing.T) {
assert.Equal(t, dummylist.Description, newdummy.Description)
assert.Equal(t, dummylist.OwnerID, doer.ID)
// Check if the user can see it
assert.True(t, dummylist.CanRead(&doer))
// Check failing with no title
list2 := List{}
err = list2.Create(&doer)
assert.Error(t, err)
assert.True(t, IsErrListTitleCannotBeEmpty(err))
// Delete it
assert.True(t, dummylist.CanDelete(&doer))
err = dummylist.Delete()
assert.NoError(t, err)
// Check creation with a nonexistant namespace
list3 := List{
Title: "test",
Description: "Lorem Ipsum",
NamespaceID: 876694,
}
err = list3.Create(&doer)
assert.Error(t, err)
assert.True(t, IsErrNamespaceDoesNotExist(err))
}