Add tests
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2020-09-06 16:08:50 +02:00
parent ed1fff40c6
commit 310dfd275b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 35 additions and 0 deletions

View File

@ -199,3 +199,13 @@
is_archived: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
-
id: 23
title: Test23
description: Lorem Ipsum
identifier: test23
owner_id: 12
namespace_id: 17
is_favorite: true
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12

View File

@ -82,3 +82,9 @@
is_archived: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 17
title: testnamespace17
description: Lorem Ipsum
owner_id: 12
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12

View File

@ -136,6 +136,8 @@ func TestNamespace_Delete(t *testing.T) {
func TestNamespace_ReadAll(t *testing.T) {
user1 := &user.User{ID: 1}
user11 := &user.User{ID: 11}
user12 := &user.User{ID: 12}
t.Run("normal", func(t *testing.T) {
n := &Namespace{}
@ -166,4 +168,21 @@ func TestNamespace_ReadAll(t *testing.T) {
assert.Equal(t, int64(-2), namespaces[0].ID) // The first one should be the one with favorites
assert.Equal(t, int64(-1), namespaces[1].ID) // The second one should be the one with the shared namespaces
})
t.Run("no favorites", func(t *testing.T) {
n := &Namespace{}
nn, _, _, err := n.ReadAll(user11, "", 1, -1)
namespaces := nn.([]*NamespaceWithLists)
assert.NoError(t, err)
// Assert the first namespace is not the favorites namespace
assert.NotEqual(t, FavoritesPseudoNamespace.ID, namespaces[0].ID)
})
t.Run("no favorite tasks but namespace", func(t *testing.T) {
n := &Namespace{}
nn, _, _, err := n.ReadAll(user12, "", 1, -1)
namespaces := nn.([]*NamespaceWithLists)
assert.NoError(t, err)
// Assert the first namespace is the favorites namespace and contains lists
assert.Equal(t, FavoritesPseudoNamespace.ID, namespaces[0].ID)
assert.NotEqual(t, 0, namespaces[0].Lists)
})
}