Add task filter for lists

Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
kolaente 2020-12-21 17:43:49 +01:00
parent 03e4bf30c2
commit 8b485a3cd8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 14 additions and 4 deletions

View File

@ -188,10 +188,7 @@ func getValueForField(field reflect.StructField, rawValue string) (value interfa
func getNativeValueForTaskField(fieldName string, comparator taskFilterComparator, value string) (nativeValue interface{}, err error) {
var realFieldName = strcase.ToCamel(fieldName)
if strings.ToLower(fieldName) == "id" {
realFieldName = "ID"
}
realFieldName := strings.ReplaceAll(strcase.ToCamel(fieldName), "Id", "ID")
field, ok := reflect.TypeOf(&Task{}).Elem().FieldByName(realFieldName)
if !ok {

View File

@ -941,6 +941,19 @@ func TestTaskCollection_ReadAll(t *testing.T) {
},
wantErr: false,
},
{
name: "filter list",
fields: fields{
FilterBy: []string{"list_id"},
FilterValue: []string{"6"},
FilterComparator: []string{"equals"},
},
args: defaultArgs,
want: []*Task{
task15,
},
wantErr: false,
},
}
for _, tt := range tests {