Kanban #393

Merged
konrad merged 14 commits from feature/kanban into master 2020-04-19 07:27:29 +00:00
4 changed files with 102 additions and 1 deletions
Showing only changes of commit 8e1a2c046c - Show all commits

View File

@ -0,0 +1,24 @@
- id: 1
title: testbucket1
list_id: 1
created_by_id: 1
created: 1587244432
updated: 1587244432
- id: 2
title: testbucket2
list_id: 1
created_by_id: 1
created: 1587244432
updated: 1587244432
- id: 3
title: testbucket3
list_id: 1
created_by_id: 1
created: 1587244432
updated: 1587244432
- id: 4
title: testbucket4 - other list
list_id: 2
created_by_id: 1
created: 1587244432
updated: 1587244432

View File

@ -7,6 +7,7 @@
index: 1
created: 1543626724
updated: 1543626724
bucket_id: 1
- id: 2
text: 'task #2 done'
done: true
@ -15,6 +16,7 @@
index: 2
created: 1543626724
updated: 1543626724
bucket_id: 1
- id: 3
text: 'task #3 high prio'
done: false
@ -24,6 +26,7 @@
created: 1543626724
updated: 1543626724
priority: 100
bucket_id: 2
- id: 4
text: 'task #4 low prio'
done: false
@ -33,6 +36,7 @@
created: 1543626724
updated: 1543626724
priority: 1
bucket_id: 2
- id: 5
text: 'task #5 higher due date'
done: false
@ -42,6 +46,7 @@
created: 1543626724
updated: 1543626724
due_date_unix: 1543636724
bucket_id: 2
- id: 6
text: 'task #6 lower due date'
done: false
@ -51,6 +56,7 @@
created: 1543626724
updated: 1543626724
due_date_unix: 1543616724
bucket_id: 3
- id: 7
text: 'task #7 with start date'
done: false
@ -60,6 +66,7 @@
created: 1543626724
updated: 1543626724
start_date_unix: 1544600000
bucket_id: 3
- id: 8
text: 'task #8 with end date'
done: false
@ -69,6 +76,7 @@
created: 1543626724
updated: 1543626724
end_date_unix: 1544700000
bucket_id: 3
- id: 9
text: 'task #9 with start and end date'
done: false

67
pkg/models/kanban_test.go Normal file
View File

@ -0,0 +1,67 @@
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2020 Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package models
import (
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert"
"testing"
)
func TestBucket_ReadAll(t *testing.T) {
db.LoadAndAssertFixtures(t)
testuser := &user.User{ID: 1}
b := &Bucket{ListID: 1}
bucketsInterface, _, _, err := b.ReadAll(testuser, "", 0, 0)
assert.NoError(t, err)
buckets, is := bucketsInterface.([]*Bucket)
assert.True(t, is)
// Assert that we have a user for each bucket
assert.Equal(t, testuser.ID, buckets[0].CreatedBy.ID)
assert.Equal(t, testuser.ID, buckets[1].CreatedBy.ID)
assert.Equal(t, testuser.ID, buckets[2].CreatedBy.ID)
assert.Equal(t, testuser.ID, buckets[3].CreatedBy.ID)
// Assert our three test buckets + one for all tasks without a bucket
assert.Len(t, buckets, 4)
// Assert all tasks are in the right bucket
assert.Len(t, buckets[0].Tasks, 10)
assert.Len(t, buckets[1].Tasks, 2)
assert.Len(t, buckets[2].Tasks, 3)
assert.Len(t, buckets[3].Tasks, 3)
// Assert we have bucket 0, 1, 2, 3 but not 4 (that belongs to a different list)
assert.Equal(t, int64(1), buckets[1].ID)
assert.Equal(t, int64(2), buckets[2].ID)
assert.Equal(t, int64(3), buckets[3].ID)
// Kinda assert all tasks are in the right buckets
assert.Equal(t, int64(0), buckets[0].Tasks[0].BucketID)
assert.Equal(t, int64(1), buckets[1].Tasks[0].BucketID)
assert.Equal(t, int64(1), buckets[1].Tasks[1].BucketID)
assert.Equal(t, int64(2), buckets[2].Tasks[0].BucketID)
assert.Equal(t, int64(2), buckets[2].Tasks[1].BucketID)
assert.Equal(t, int64(2), buckets[2].Tasks[2].BucketID)
assert.Equal(t, int64(3), buckets[3].Tasks[0].BucketID)
assert.Equal(t, int64(3), buckets[3].Tasks[1].BucketID)
assert.Equal(t, int64(3), buckets[3].Tasks[2].BucketID)
}

View File

@ -56,7 +56,9 @@ func SetupTests() {
"teams",
"users",
"users_list",
"users_namespace")
"users_namespace",
"buckets",
)
if err != nil {
log.Fatal(err)
}