~ewintr/gte

3d1f5361c8f3b40e68fa2b2818cca86f84fcc2d8 — Erik Winter 2 months ago d264ed0
apply local updates list req
2 files changed, 31 insertions(+), 0 deletions(-)

M internal/process/list.go
M internal/process/list_test.go
M internal/process/list.go => internal/process/list.go +8 -0
@@ 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

M internal/process/list_test.go => internal/process/list_test.go +23 -0
@@ 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)
	})
}