apply local updates list req
This commit is contained in:
parent
d264ed0040
commit
3d1f5361c8
|
@ -19,6 +19,7 @@ type ListReqs struct {
|
||||||
IncludeBefore bool
|
IncludeBefore bool
|
||||||
Folder string
|
Folder string
|
||||||
Project string
|
Project string
|
||||||
|
ApplyUpdates bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr ListReqs) Valid() bool {
|
func (lr ListReqs) Valid() bool {
|
||||||
|
@ -61,6 +62,13 @@ func (l *List) Process() (*ListResult, error) {
|
||||||
return &ListResult{}, fmt.Errorf("%w: %v", ErrListProcess, err)
|
return &ListResult{}, fmt.Errorf("%w: %v", ErrListProcess, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updates
|
||||||
|
if l.reqs.ApplyUpdates {
|
||||||
|
for i := range potentialTasks {
|
||||||
|
potentialTasks[i].ApplyUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// folder
|
// folder
|
||||||
if l.reqs.Folder != "" {
|
if l.reqs.Folder != "" {
|
||||||
var folderTasks []*task.LocalTask
|
var folderTasks []*task.LocalTask
|
||||||
|
|
|
@ -111,4 +111,27 @@ func TestListProcess(t *testing.T) {
|
||||||
test.Equals(t, sExp, sAct)
|
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)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue