apply local updates list req

This commit is contained in:
Erik Winter 2021-09-06 07:24:29 +02:00
parent d264ed0040
commit 3d1f5361c8
2 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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)
})
}