From 2366a8ad411e59e0d918ebeb94c343f6938e7d2d Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Mon, 10 Jul 2023 13:41:11 +0200 Subject: [PATCH] Fix has_ward ordering --- flows/routers/cases/tests.go | 15 ++++++++------- flows/routers/cases/tests_test.go | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/flows/routers/cases/tests.go b/flows/routers/cases/tests.go index c3184f9aa..72836504f 100644 --- a/flows/routers/cases/tests.go +++ b/flows/routers/cases/tests.go @@ -664,11 +664,11 @@ func HasDistrict(env envs.Environment, args ...types.XValue) types.XValue { // HasWard tests whether a ward name is contained in the `text` // -// @(has_ward("Gisozi", "Gasabo", "Kigali").match) -> Rwanda > Kigali City > Gasabo > Gisozi -// @(has_ward("I live in Gisozi", "Gasabo", "Kigali").match) -> Rwanda > Kigali City > Gasabo > Gisozi -// @(has_ward("Gisozi", "Gasabo", "Brooklyn")) -> false -// @(has_ward("Gisozi", "Brooklyn", "Kigali")) -> false -// @(has_ward("Brooklyn", "Gasabo", "Kigali")) -> false +// @(has_ward("Gisozi", "Kigali", "Gasabo").match) -> Rwanda > Kigali City > Gasabo > Gisozi +// @(has_ward("I live in Gisozi", "Kigali", "Gasabo").match) -> Rwanda > Kigali City > Gasabo > Gisozi +// @(has_ward("Gisozi", "Brooklyn" , "Gasabo")) -> false +// @(has_ward("Gisozi", "Kigali", "Brooklyn")) -> false +// @(has_ward("Brooklyn", "Kigali", "Gasabo")) -> false // @(has_ward("Gasabo")) -> false // @(has_ward("Gisozi").match) -> Rwanda > Kigali City > Gasabo > Gisozi // @@ -691,10 +691,11 @@ func HasWard(env envs.Environment, args ...types.XValue) types.XValue { return xerr } if len(args) == 3 { - if districtText, xerr = types.ToXText(env, args[1]); xerr != nil { + if stateText, xerr = types.ToXText(env, args[1]); xerr != nil { return xerr } - if stateText, xerr = types.ToXText(env, args[2]); xerr != nil { + + if districtText, xerr = types.ToXText(env, args[2]); xerr != nil { return xerr } } diff --git a/flows/routers/cases/tests_test.go b/flows/routers/cases/tests_test.go index b2101695e..16c14d6d0 100644 --- a/flows/routers/cases/tests_test.go +++ b/flows/routers/cases/tests_test.go @@ -323,10 +323,10 @@ var testTests = []struct { {"has_district", []types.XValue{xs("xyz"), xs("kigali")}, falseResult}, {"has_district", []types.XValue{ERROR}, ERROR}, - {"has_ward", []types.XValue{xs("Gisozi"), xs("Gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, - {"has_ward", []types.XValue{xs("I live in gisozi"), xs("Gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, + {"has_ward", []types.XValue{xs("Gisozi"), xs("kigali"), xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, + {"has_ward", []types.XValue{xs("I live in gisozi"), xs("kigali"), xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, {"has_ward", []types.XValue{xs("Gisozi")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, - {"has_ward", []types.XValue{xs("xyz"), xs("Gasabo"), xs("kigali")}, falseResult}, + {"has_ward", []types.XValue{xs("xyz"), xs("kigali"), xs("Gasabo")}, falseResult}, {"has_ward", []types.XValue{ERROR}, ERROR}, {