1
0

Add support for migrating todoist boards (#732)

Add migrating buckets to converting todoist to vikunja structure

Add buckets migration

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/732
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad
2020-12-16 14:19:09 +00:00
parent 90ae940a6b
commit 00ed5884b4
5 changed files with 128 additions and 10 deletions

View File

@ -42,6 +42,12 @@ func TestInsertFromStructure(t *testing.T) {
{
Title: "Testlist1",
Description: "Something",
Buckets: []*models.Bucket{
{
ID: 1234,
Title: "Test Bucket",
},
},
Tasks: []*models.Task{
{
Title: "Task1",
@ -92,6 +98,14 @@ func TestInsertFromStructure(t *testing.T) {
},
},
},
{
Title: "Task in a bucket",
BucketID: 1234,
},
{
Title: "Task in a nonexisting bucket",
BucketID: 1111,
},
},
},
},
@ -99,5 +113,23 @@ func TestInsertFromStructure(t *testing.T) {
}
err := InsertFromStructure(testStructure, u)
assert.NoError(t, err)
db.AssertExists(t, "namespaces", map[string]interface{}{
"title": testStructure[0].Namespace.Title,
"description": testStructure[0].Namespace.Description,
}, false)
db.AssertExists(t, "list", map[string]interface{}{
"title": testStructure[0].Lists[0].Title,
"description": testStructure[0].Lists[0].Description,
}, false)
db.AssertExists(t, "tasks", map[string]interface{}{
"title": testStructure[0].Lists[0].Tasks[5].Title,
"bucket_id": testStructure[0].Lists[0].Buckets[0].ID,
}, false)
db.AssertMissing(t, "tasks", map[string]interface{}{
"title": testStructure[0].Lists[0].Tasks[6].Title,
"bucket_id": 1111, // No task with that bucket should exist
})
assert.NotEqual(t, 0, testStructure[0].Lists[0].Tasks[0].BucketID) // Should get the default bucket
assert.NotEqual(t, 0, testStructure[0].Lists[0].Tasks[6].BucketID) // Should get the default bucket
})
}