From 3d1f5361c8f3b40e68fa2b2818cca86f84fcc2d8 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Mon, 6 Sep 2021 07:24:29 +0200 Subject: [PATCH] apply local updates list req --- internal/process/list.go | 8 ++++++++ internal/process/list_test.go | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/process/list.go b/internal/process/list.go index 69918d7..0c36bc0 100644 --- a/internal/process/list.go +++ b/internal/process/list.go @@ -19,6 +19,7 @@ type ListReqs struct { IncludeBefore bool Folder string Project string + ApplyUpdates bool } func (lr ListReqs) Valid() bool { @@ -61,6 +62,13 @@ func (l *List) Process() (*ListResult, error) { return &ListResult{}, fmt.Errorf("%w: %v", ErrListProcess, err) } + // updates + if l.reqs.ApplyUpdates { + for i := range potentialTasks { + potentialTasks[i].ApplyUpdate() + } + } + // folder if l.reqs.Folder != "" { var folderTasks []*task.LocalTask diff --git a/internal/process/list_test.go b/internal/process/list_test.go index 03b7d97..8810f9c 100644 --- a/internal/process/list_test.go +++ b/internal/process/list_test.go @@ -111,4 +111,27 @@ func TestListProcess(t *testing.T) { test.Equals(t, sExp, sAct) }) } + + t.Run("applyupdates", func(t *testing.T) { + mem := storage.NewMemory() + test.OK(t, mem.SetTasks([]*task.Task{task2, task4})) + lu := &task.LocalUpdate{ + ForVersion: task4.Version, + Fields: []string{task.FIELD_PROJECT}, + Project: "project4", + } + test.OK(t, mem.SetLocalUpdate(task4.Id, lu)) + + lr := process.ListReqs{ + Project: "project4", + ApplyUpdates: true, + } + + list := process.NewList(mem, lr) + actRes, err := list.Process() + test.OK(t, err) + act := actRes.Tasks + test.Equals(t, 1, len(act)) + test.Equals(t, "project4", act[0].Project) + }) }