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:
Harry Smith
2018-11-05 17:41:59 +00:00
committed by Reed Allman
parent 3a383049f9
commit 3f0d4804b2
2 changed files with 13 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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 {