Task filters (#243)
Fix not returning errors Fix integration tests Add more tests Make task filtering actually work Change tests Fix using filter conditions Fix test Remove unused fields Fix static check Remove start and end date fields on task collection Fix misspell add filter logic when getting tasks Add parsing filter query parameters into task filters Start adding support for filters Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/243
This commit is contained in:
@ -44,7 +44,7 @@ func TestSortParamValidation(t *testing.T) {
|
||||
})
|
||||
})
|
||||
t.Run("Test valid sort by", func(t *testing.T) {
|
||||
for _, test := range []sortProperty{
|
||||
for _, test := range []string{
|
||||
taskPropertyID,
|
||||
taskPropertyText,
|
||||
taskPropertyDescription,
|
||||
@ -63,10 +63,10 @@ func TestSortParamValidation(t *testing.T) {
|
||||
taskPropertyCreated,
|
||||
taskPropertyUpdated,
|
||||
} {
|
||||
t.Run(test.String(), func(t *testing.T) {
|
||||
t.Run(test, func(t *testing.T) {
|
||||
s := &sortParam{
|
||||
orderBy: orderAscending,
|
||||
sortBy: test,
|
||||
sortBy: sortProperty(test),
|
||||
}
|
||||
err := s.validate()
|
||||
assert.NoError(t, err)
|
||||
@ -89,7 +89,7 @@ func TestSortParamValidation(t *testing.T) {
|
||||
}
|
||||
err := s.validate()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrInvalidSortParam(err))
|
||||
assert.True(t, IsErrInvalidTaskField(err))
|
||||
})
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ type taskSortTestCase struct {
|
||||
name string
|
||||
wantAsc []*Task
|
||||
wantDesc []*Task
|
||||
sortProperty sortProperty
|
||||
sortProperty string
|
||||
}
|
||||
|
||||
var taskSortTestCases = []taskSortTestCase{
|
||||
@ -692,7 +692,7 @@ func TestTaskSort(t *testing.T) {
|
||||
t.Run("asc default", func(t *testing.T) {
|
||||
by := []*sortParam{
|
||||
{
|
||||
sortBy: testCase.sortProperty,
|
||||
sortBy: sortProperty(testCase.sortProperty),
|
||||
},
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ func TestTaskSort(t *testing.T) {
|
||||
t.Run("asc", func(t *testing.T) {
|
||||
by := []*sortParam{
|
||||
{
|
||||
sortBy: testCase.sortProperty,
|
||||
sortBy: sortProperty(testCase.sortProperty),
|
||||
orderBy: orderAscending,
|
||||
},
|
||||
}
|
||||
@ -729,7 +729,7 @@ func TestTaskSort(t *testing.T) {
|
||||
t.Run("desc", func(t *testing.T) {
|
||||
by := []*sortParam{
|
||||
{
|
||||
sortBy: testCase.sortProperty,
|
||||
sortBy: sortProperty(testCase.sortProperty),
|
||||
orderBy: orderDescending,
|
||||
},
|
||||
}
|
||||
@ -767,11 +767,11 @@ func TestTaskSort(t *testing.T) {
|
||||
}
|
||||
sortParams := []*sortParam{
|
||||
{
|
||||
sortBy: taskPropertyDone,
|
||||
sortBy: sortProperty(taskPropertyDone),
|
||||
orderBy: orderAscending,
|
||||
},
|
||||
{
|
||||
sortBy: taskPropertyID,
|
||||
sortBy: sortProperty(taskPropertyID),
|
||||
orderBy: orderDescending,
|
||||
},
|
||||
}
|
||||
@ -804,11 +804,11 @@ func TestTaskSort(t *testing.T) {
|
||||
}
|
||||
sortParams := []*sortParam{
|
||||
{
|
||||
sortBy: taskPropertyDone,
|
||||
sortBy: sortProperty(taskPropertyDone),
|
||||
orderBy: orderAscending,
|
||||
},
|
||||
{
|
||||
sortBy: taskPropertyText,
|
||||
sortBy: sortProperty(taskPropertyText),
|
||||
orderBy: orderDescending,
|
||||
},
|
||||
}
|
||||
@ -841,11 +841,11 @@ func TestTaskSort(t *testing.T) {
|
||||
}
|
||||
sortParams := []*sortParam{
|
||||
{
|
||||
sortBy: taskPropertyDone,
|
||||
sortBy: sortProperty(taskPropertyDone),
|
||||
orderBy: orderDescending,
|
||||
},
|
||||
{
|
||||
sortBy: taskPropertyText,
|
||||
sortBy: sortProperty(taskPropertyText),
|
||||
orderBy: orderAscending,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user