mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fix filtering by name when getting list of funcs (#1295)
* Fix filtering by name when getting list of funcs * Add datastore test for function list name filter * Fix tests
This commit is contained in:
@@ -727,6 +727,16 @@ func RunFnsTest(t *testing.T, dsf DataStoreFunc, rp ResourceProvider) {
|
||||
} else if !gendFns[2].EqualsWithAnnotationSubset(fns.Items[1]) {
|
||||
t.Fatalf("expected `func.Name` to be `%#v` but it was `%#v`", gendFns[2], fns.Items[1])
|
||||
}
|
||||
|
||||
fns, err = ds.GetFns(ctx, &models.FnFilter{AppID: testApp.ID, Name: f1.Name})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
if len(fns.Items) != 1 {
|
||||
t.Fatalf("expected result count to be 1, got %d", len(fns.Items))
|
||||
} else if !f1.EqualsWithAnnotationSubset(fns.Items[0]) {
|
||||
t.Fatalf("expected function list to contain function %s, got %#v", f1.Name, fns.Items[0].Name)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("delete with empty fn name", func(t *testing.T) {
|
||||
|
||||
@@ -934,6 +934,9 @@ func buildFilterFnQuery(filter *models.FnFilter) (string, []interface{}, error)
|
||||
}
|
||||
args = where(&b, args, "name>?", string(s))
|
||||
}
|
||||
if filter.Name != "" {
|
||||
args = where(&b, args, "name=?", filter.Name)
|
||||
}
|
||||
|
||||
fmt.Fprintf(&b, ` ORDER BY name ASC`)
|
||||
if filter.PerPage > 0 {
|
||||
|
||||
Reference in New Issue
Block a user