From 5882b8cd1e7f44170b6c59c7fa4585dbc7e95374 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Tue, 19 Sep 2023 10:15:55 -0500 Subject: [PATCH] Add mores tests for arabic-farsi collation --- flows/routers/cases/tests_test.go | 526 +++++++++++++++--------------- 1 file changed, 272 insertions(+), 254 deletions(-) diff --git a/flows/routers/cases/tests_test.go b/flows/routers/cases/tests_test.go index 5102d065a..67c45c326 100644 --- a/flows/routers/cases/tests_test.go +++ b/flows/routers/cases/tests_test.go @@ -34,6 +34,15 @@ var falseResult = cases.FalseResult var ERROR = types.NewXErrorf("any error") var kgl, _ = time.LoadLocation("Africa/Kigali") +var dmy = envs.NewBuilder(). + WithDateFormat(envs.DateFormatDayMonthYear). + WithTimeFormat(envs.TimeFormatHourMinuteSecond). + WithTimezone(kgl). + WithDefaultCountry(i18n.Country("RW")). + Build() +var ara = envs.NewBuilder(). + WithInputCollation(envs.CollationArabicFarsi). + Build() var assetsJSON = `{ "flows": [ @@ -94,262 +103,271 @@ var assetsJSON = `{ var testTests = []struct { name string + env envs.Environment args []types.XValue expected types.XValue }{ - {"has_error", []types.XValue{xs("hello")}, falseResult}, - {"has_error", []types.XValue{nil}, falseResult}, - {"has_error", []types.XValue{types.NewXErrorf("I am error")}, result(xs("I am error"))}, - {"has_error", []types.XValue{}, ERROR}, - - {"has_text", []types.XValue{xs("hello")}, result(xs("hello"))}, - {"has_text", []types.XValue{xs(" ")}, falseResult}, - {"has_text", []types.XValue{nil}, falseResult}, - {"has_text", []types.XValue{xs("one"), xs("two")}, ERROR}, - {"has_text", []types.XValue{ERROR}, ERROR}, - - {"has_only_text", []types.XValue{xs("hello"), xs("hello")}, result(xs("hello"))}, - {"has_only_text", []types.XValue{xs("hello-world"), xs("hello-world")}, result(xs("hello-world"))}, - {"has_only_text", []types.XValue{xs("HELLO"), xs("hello")}, falseResult}, // case sensitive - {"has_only_text", []types.XValue{xs("hello"), ERROR}, ERROR}, - {"has_only_text", []types.XValue{ERROR, xs("hello")}, ERROR}, - - {"has_beginning", []types.XValue{xs("hello"), xs("hell")}, result(xs("hell"))}, - {"has_beginning", []types.XValue{xs(" HelloThere"), xs("hello")}, result(xs("Hello"))}, - {"has_beginning", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_beginning", []types.XValue{nil, xs("hell")}, falseResult}, - {"has_beginning", []types.XValue{xs("hello"), nil}, falseResult}, - {"has_beginning", []types.XValue{xs(""), xs("hello")}, falseResult}, - {"has_beginning", []types.XValue{xs("hel"), xs("hello")}, falseResult}, - {"has_beginning", []types.XValue{ERROR, ERROR}, ERROR}, - {"has_beginning", []types.XValue{}, ERROR}, - - {"has_any_word", []types.XValue{xs("this.is.my.word"), xs("WORD word2 word")}, result(xs("word"))}, - {"has_any_word", []types.XValue{xs("this.is.my.βήτα"), xs("βήτα")}, result(xs("βήτα"))}, - {"has_any_word", []types.XValue{xs("I say to you📴"), xs("📴")}, result(xs("📴"))}, - {"has_any_word", []types.XValue{xs("this World too"), xs("world")}, result(xs("World"))}, - {"has_any_word", []types.XValue{xs("I don't like it"), xs("don't dont")}, result(xs("don't"))}, - {"has_any_word", []types.XValue{xs("BUT not this one"), xs("world")}, falseResult}, - {"has_any_word", []types.XValue{xs(""), xs("world")}, falseResult}, - {"has_any_word", []types.XValue{xs("world"), xs("foo")}, falseResult}, - {"has_any_word", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_any_word", []types.XValue{xs("but foo"), nil}, falseResult}, - {"has_any_word", []types.XValue{nil, xs("but foo")}, falseResult}, - {"has_any_word", []types.XValue{}, ERROR}, - - {"has_all_words", []types.XValue{xs("this.is.my.word"), xs("WORD word")}, result(xs("word"))}, - {"has_all_words", []types.XValue{xs("this World too"), xs("world too")}, result(xs("World too"))}, - {"has_all_words", []types.XValue{xs("BUT not this one"), xs("world")}, falseResult}, - {"has_all_words", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_all_words", []types.XValue{}, ERROR}, - - {"has_phrase", []types.XValue{xs("you Must resist"), xs("must resist")}, result(xs("Must resist"))}, - {"has_phrase", []types.XValue{xs("this world Too"), xs("world too")}, result(xs("world Too"))}, - {"has_phrase", []types.XValue{xs("this world Too"), xs("")}, result(xs(""))}, - {"has_phrase", []types.XValue{xs("this is not world"), xs("this world")}, falseResult}, - {"has_phrase", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_phrase", []types.XValue{}, ERROR}, - - {"has_only_phrase", []types.XValue{xs("Must resist"), xs("must resist")}, result(xs("Must resist"))}, - {"has_only_phrase", []types.XValue{xs(" world Too "), xs("world too")}, result(xs("world Too"))}, - {"has_only_phrase", []types.XValue{xs("this world Too"), xs("")}, falseResult}, - {"has_only_phrase", []types.XValue{xs(""), xs("")}, result(xs(""))}, - {"has_only_phrase", []types.XValue{xs("this world is my world"), xs("this world")}, falseResult}, - {"has_only_phrase", []types.XValue{xs("this world"), xs("this mighty")}, falseResult}, - {"has_only_phrase", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_only_phrase", []types.XValue{}, ERROR}, - - {"has_beginning", []types.XValue{xs("Must resist"), xs("must resist")}, result(xs("Must resist"))}, - {"has_beginning", []types.XValue{xs(" 2061212"), xs("206")}, result(xs("206"))}, - {"has_beginning", []types.XValue{xs(" world Too foo"), xs("world too")}, result(xs("world Too"))}, - {"has_beginning", []types.XValue{xs("but this world"), xs("this world")}, falseResult}, - {"has_beginning", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_beginning", []types.XValue{}, ERROR}, - - {"has_pattern", []types.XValue{xs("x"), xs(`<\w+>`)}, resultWithExtra(xs(""), types.NewXObject(map[string]types.XValue{"0": xs("")}))}, - {"has_pattern", []types.XValue{xs("x"), xs(`HTML`)}, resultWithExtra(xs("html"), types.NewXObject(map[string]types.XValue{"0": xs("html")}))}, - {"has_pattern", []types.XValue{xs("x"), xs(`(?-i)HTML`)}, falseResult}, - {"has_pattern", []types.XValue{xs("12345"), xs(`\A\d{5}\z`)}, resultWithExtra(xs("12345"), types.NewXObject(map[string]types.XValue{"0": xs("12345")}))}, - {"has_pattern", []types.XValue{xs("12345 "), xs(`\A\d{5}\z`)}, falseResult}, - {"has_pattern", []types.XValue{xs(" 12345"), xs(`\A\d{5}\z`)}, falseResult}, - {"has_pattern", []types.XValue{xs(`hi there 😀`), xs("[\U0001F600-\U0001F64F]")}, resultWithExtra(xs("😀"), types.NewXObject(map[string]types.XValue{"0": xs("😀")}))}, - {"has_pattern", []types.XValue{xs(`hi there`), xs("[\U0001F600-\U0001F64F]")}, falseResult}, - {"has_pattern", []types.XValue{xs(`hi there 😂`), xs("[😀-🙏]")}, resultWithExtra(xs("😂"), types.NewXObject(map[string]types.XValue{"0": xs("😂")}))}, - {"has_pattern", []types.XValue{xs("x"), xs(`[`)}, ERROR}, - {"has_pattern", []types.XValue{}, ERROR}, - - {"has_number", []types.XValue{xs("the number 10")}, result(xn("10"))}, - {"has_number", []types.XValue{xs("the number -10")}, result(xn("-10"))}, - {"has_number", []types.XValue{xs("1-15")}, result(xn("1"))}, - {"has_number", []types.XValue{xs("24ans")}, result(xn("24"))}, - {"has_number", []types.XValue{xs("J'AI 20ANS")}, result(xn("20"))}, - {"has_number", []types.XValue{xs("1,000,000")}, result(xn("1000000"))}, - {"has_number", []types.XValue{xs("the number 10")}, result(xn("10"))}, - {"has_number", []types.XValue{xs("O número é 500")}, result(xn("500"))}, - {"has_number", []types.XValue{xs("another is -12.51")}, result(xn("-12.51"))}, - {"has_number", []types.XValue{xs("hi.51")}, result(xn("51"))}, - {"has_number", []types.XValue{xs("hi .51")}, result(xn("0.51"))}, - {"has_number", []types.XValue{xs(".51")}, result(xn("0.51"))}, - {"has_number", []types.XValue{xs("١٢٣٤")}, result(xn("1234"))}, // Arabic - {"has_number", []types.XValue{xs("۱۲۳۴")}, result(xn("1234"))}, // Eastern Arabic - {"has_number", []types.XValue{xs("٠.٥")}, result(xn("0.5"))}, - {"has_number", []types.XValue{xs("nothing here")}, falseResult}, - {"has_number", []types.XValue{xs("lOO")}, falseResult}, // no longer do substitutions - {"has_number", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number", []types.XValue{}, ERROR}, - - {"has_number_lt", []types.XValue{xs("the number 10"), xs("11")}, result(xn("10"))}, - {"has_number_lt", []types.XValue{xs("another is -12.51"), xs("12")}, result(xn("-12.51"))}, - {"has_number_lt", []types.XValue{xs("١٠"), xs("11")}, result(xn("10"))}, - {"has_number_lt", []types.XValue{xs("nothing here"), xs("12")}, falseResult}, - {"has_number_lt", []types.XValue{xs("too big 15"), xs("12")}, falseResult}, - {"has_number_lt", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number_lt", []types.XValue{xs("but foo"), falseResult}, ERROR}, - {"has_number_lt", []types.XValue{nil, xs("but foo")}, ERROR}, - {"has_number_lt", []types.XValue{}, ERROR}, - - {"has_number_lte", []types.XValue{xs("the number 10"), xs("11")}, result(xn("10"))}, - {"has_number_lte", []types.XValue{xs("another is -12.51"), xs("12")}, result(xn("-12.51"))}, - {"has_number_lte", []types.XValue{xs("١٠"), xs("11")}, result(xn("10"))}, - {"has_number_lte", []types.XValue{xs("nothing here"), xs("12")}, falseResult}, - {"has_number_lte", []types.XValue{xs("too big 15"), xs("12")}, falseResult}, - {"has_number_lte", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number_lte", []types.XValue{}, ERROR}, - - {"has_number_eq", []types.XValue{xs("the number 10"), xs("10")}, result(xn("10"))}, - {"has_number_eq", []types.XValue{xs("another is -12.51"), xs("-12.51")}, result(xn("-12.51"))}, - {"has_number_eq", []types.XValue{xs("١٠"), xs("10")}, result(xn("10"))}, - {"has_number_eq", []types.XValue{xs("nothing here"), xs("12")}, falseResult}, - {"has_number_eq", []types.XValue{xs("wrong .51"), xs(".61")}, falseResult}, - {"has_number_eq", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number_eq", []types.XValue{}, ERROR}, - - {"has_number_gte", []types.XValue{xs("the number 10"), xs("9")}, result(xn("10"))}, - {"has_number_gte", []types.XValue{xs("another is -12.51"), xs("-13")}, result(xn("-12.51"))}, - {"has_number_gte", []types.XValue{xs("١٠"), xs("9")}, result(xn("10"))}, - {"has_number_gte", []types.XValue{xs("nothing here"), xs("12")}, falseResult}, - {"has_number_gte", []types.XValue{xs("too small -12"), xs("-11")}, falseResult}, - {"has_number_gte", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number_gte", []types.XValue{}, ERROR}, - - {"has_number_gt", []types.XValue{xs("the number 10"), xs("9")}, result(xn("10"))}, - {"has_number_gt", []types.XValue{xs("another is -12.51"), xs("-13")}, result(xn("-12.51"))}, - {"has_number_gt", []types.XValue{xs("١٠"), xs("9")}, result(xn("10"))}, - {"has_number_gt", []types.XValue{xs("nothing here"), xs("12")}, falseResult}, - {"has_number_gt", []types.XValue{xs("not great -12.51"), xs("-12.51")}, falseResult}, - {"has_number_gt", []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, - {"has_number_gt", []types.XValue{}, ERROR}, - - {"has_number_between", []types.XValue{xs("the number 10"), xs("8"), xs("12")}, result(xn("10"))}, - {"has_number_between", []types.XValue{xs("24ans"), xn("20"), xn("24")}, result(xn("24"))}, - {"has_number_between", []types.XValue{xs("another is -12.51"), xs("-12.51"), xs("-10")}, result(xn("-12.51"))}, - {"has_number_between", []types.XValue{xs("١٠"), xs("8"), xs("12")}, result(xn("10"))}, - {"has_number_between", []types.XValue{xs("nothing here"), xs("10"), xs("15")}, falseResult}, - {"has_number_between", []types.XValue{xs("one"), xs("two")}, ERROR}, - {"has_number_between", []types.XValue{xs("but foo"), nil, xs("10")}, ERROR}, - {"has_number_between", []types.XValue{nil, xs("but foo"), xs("10")}, ERROR}, - {"has_number_between", []types.XValue{xs("a string"), xs("10"), xs("not number")}, ERROR}, - {"has_number_between", []types.XValue{}, ERROR}, - - {"has_date", []types.XValue{xs("last date was 1.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, - {"has_date", []types.XValue{xs("last date was 1.10.99")}, result(xd(time.Date(1999, 10, 1, 15, 24, 30, 123456000, kgl)))}, - {"has_date", []types.XValue{xs("this isn't a valid date 33.2.99")}, falseResult}, - {"has_date", []types.XValue{xs("no date at all")}, falseResult}, - {"has_date", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_date", []types.XValue{}, ERROR}, - - {"has_date_lt", []types.XValue{xs("last date was 1.10.2017"), xs("3.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, - {"has_date_lt", []types.XValue{xs("last date was 1.10.99"), xs("3.10.98")}, falseResult}, - {"has_date_lt", []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, - {"has_date_lt", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_date_lt", []types.XValue{xs("last date was 1.10.2017"), nil}, ERROR}, - {"has_date_lt", []types.XValue{nil, xs("but foo")}, ERROR}, - {"has_date_lt", []types.XValue{}, ERROR}, - - {"has_date_eq", []types.XValue{xs("last date was 1.10.2017"), xs("1.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, - {"has_date_eq", []types.XValue{xs("last date was 1.10.99"), xs("3.10.98")}, falseResult}, - {"has_date_eq", []types.XValue{xs("2017-10-01T23:55:55.123456+02:00"), xs("1.10.2017")}, result(xd(time.Date(2017, 10, 1, 23, 55, 55, 123456000, kgl)))}, - {"has_date_eq", []types.XValue{xs("2017-10-01T23:55:55.123456+01:00"), xs("1.10.2017")}, falseResult}, // would have been 2017-10-02 in env timezone - {"has_date_eq", []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, - {"has_date_eq", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_date_eq", []types.XValue{}, ERROR}, - - {"has_date_gt", []types.XValue{xs("last date was 1.10.2017"), xs("3.10.2016")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, - {"has_date_gt", []types.XValue{xs("last date was 1.10.99"), xs("3.10.01")}, falseResult}, - {"has_date_gt", []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, - {"has_date_gt", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_date_gt", []types.XValue{}, ERROR}, - - {"has_time", []types.XValue{xs("last time was 10:30")}, result(xt(dates.NewTimeOfDay(10, 30, 0, 0)))}, - {"has_time", []types.XValue{xs("this isn't a valid time 59:77")}, falseResult}, - {"has_time", []types.XValue{xs("no time at all")}, falseResult}, - {"has_time", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_time", []types.XValue{}, ERROR}, - - {"has_email", []types.XValue{xs("my email is foo@bar.com.")}, result(xs("foo@bar.com"))}, - {"has_email", []types.XValue{xs("my email is ")}, result(xs("foo~$1+spam@bar-2.com"))}, - {"has_email", []types.XValue{xs("FOO@bar.whatzit")}, result(xs("FOO@bar.whatzit"))}, - {"has_email", []types.XValue{xs("FOO@βήτα.whatzit")}, result(xs("FOO@βήτα.whatzit"))}, - {"has_email", []types.XValue{xs("email is foo @ bar . com")}, falseResult}, - {"has_email", []types.XValue{xs("email is foo@bar")}, falseResult}, - {"has_email", []types.XValue{nil}, falseResult}, - {"has_email", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_email", []types.XValue{}, ERROR}, + {"has_error", dmy, []types.XValue{xs("hello")}, falseResult}, + {"has_error", dmy, []types.XValue{nil}, falseResult}, + {"has_error", dmy, []types.XValue{types.NewXErrorf("I am error")}, result(xs("I am error"))}, + {"has_error", dmy, []types.XValue{}, ERROR}, + + {"has_text", dmy, []types.XValue{xs("hello")}, result(xs("hello"))}, + {"has_text", dmy, []types.XValue{xs(" ")}, falseResult}, + {"has_text", dmy, []types.XValue{nil}, falseResult}, + {"has_text", dmy, []types.XValue{xs("one"), xs("two")}, ERROR}, + {"has_text", dmy, []types.XValue{ERROR}, ERROR}, + + {"has_only_text", dmy, []types.XValue{xs("hello"), xs("hello")}, result(xs("hello"))}, + {"has_only_text", dmy, []types.XValue{xs("hello-world"), xs("hello-world")}, result(xs("hello-world"))}, + {"has_only_text", dmy, []types.XValue{xs("HELLO"), xs("hello")}, falseResult}, // case sensitive + {"has_only_text", dmy, []types.XValue{xs("hello"), ERROR}, ERROR}, + {"has_only_text", dmy, []types.XValue{ERROR, xs("hello")}, ERROR}, + + {"has_beginning", dmy, []types.XValue{xs("hello"), xs("hell")}, result(xs("hell"))}, + {"has_beginning", dmy, []types.XValue{xs(" HelloThere"), xs("hello")}, result(xs("Hello"))}, + {"has_beginning", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_beginning", dmy, []types.XValue{nil, xs("hell")}, falseResult}, + {"has_beginning", dmy, []types.XValue{xs("hello"), nil}, falseResult}, + {"has_beginning", dmy, []types.XValue{xs(""), xs("hello")}, falseResult}, + {"has_beginning", dmy, []types.XValue{xs("hel"), xs("hello")}, falseResult}, + {"has_beginning", dmy, []types.XValue{ERROR, ERROR}, ERROR}, + {"has_beginning", dmy, []types.XValue{}, ERROR}, + + {"has_any_word", dmy, []types.XValue{xs("this.is.my.word"), xs("WORD word2 word")}, result(xs("word"))}, + {"has_any_word", dmy, []types.XValue{xs("this.is.my.βήτα"), xs("βήτα")}, result(xs("βήτα"))}, + {"has_any_word", dmy, []types.XValue{xs("I say to you📴"), xs("📴")}, result(xs("📴"))}, + {"has_any_word", dmy, []types.XValue{xs("this World too"), xs("world")}, result(xs("World"))}, + {"has_any_word", dmy, []types.XValue{xs("I don't like it"), xs("don't dont")}, result(xs("don't"))}, + {"has_any_word", dmy, []types.XValue{xs("BUT not this one"), xs("world")}, falseResult}, + {"has_any_word", dmy, []types.XValue{xs(""), xs("world")}, falseResult}, + {"has_any_word", dmy, []types.XValue{xs("world"), xs("foo")}, falseResult}, + {"has_any_word", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_any_word", dmy, []types.XValue{xs("but foo"), nil}, falseResult}, + {"has_any_word", dmy, []types.XValue{nil, xs("but foo")}, falseResult}, + {"has_any_word", dmy, []types.XValue{xs("بلی"), xs("بلی")}, result(xs("بلی"))}, // using regular collation + {"has_any_word", dmy, []types.XValue{xs("بلي"), xs("بلی")}, falseResult}, // not quite the same yeh + {"has_any_word", dmy, []types.XValue{xs("بلى"), xs("بلی")}, falseResult}, // not quite the same yeh + {"has_any_word", ara, []types.XValue{xs("بلی"), xs("بلی")}, result(xs("بلی"))}, // using ara-far collation + {"has_any_word", ara, []types.XValue{xs("بلي"), xs("بلی")}, result(xs("بلي"))}, // using ara-far collation + {"has_any_word", ara, []types.XValue{xs("بلى"), xs("بلی")}, result(xs("بلى"))}, // using ara-far collation + {"has_any_word", dmy, []types.XValue{}, ERROR}, + + {"has_all_words", dmy, []types.XValue{xs("this.is.my.word"), xs("WORD word")}, result(xs("word"))}, + {"has_all_words", dmy, []types.XValue{xs("this World too"), xs("world too")}, result(xs("World too"))}, + {"has_all_words", dmy, []types.XValue{xs("BUT not this one"), xs("world")}, falseResult}, + {"has_all_words", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_all_words", dmy, []types.XValue{}, ERROR}, + + {"has_phrase", dmy, []types.XValue{xs("you Must resist"), xs("must resist")}, result(xs("Must resist"))}, + {"has_phrase", dmy, []types.XValue{xs("this world Too"), xs("world too")}, result(xs("world Too"))}, + {"has_phrase", dmy, []types.XValue{xs("this world Too"), xs("")}, result(xs(""))}, + {"has_phrase", dmy, []types.XValue{xs("this is not world"), xs("this world")}, falseResult}, + {"has_phrase", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_phrase", dmy, []types.XValue{}, ERROR}, + + {"has_only_phrase", dmy, []types.XValue{xs("Must resist"), xs("must resist")}, result(xs("Must resist"))}, + {"has_only_phrase", dmy, []types.XValue{xs(" world Too "), xs("world too")}, result(xs("world Too"))}, + {"has_only_phrase", dmy, []types.XValue{xs("this world Too"), xs("")}, falseResult}, + {"has_only_phrase", dmy, []types.XValue{xs(""), xs("")}, result(xs(""))}, + {"has_only_phrase", dmy, []types.XValue{xs("this world is my world"), xs("this world")}, falseResult}, + {"has_only_phrase", dmy, []types.XValue{xs("this world"), xs("this mighty")}, falseResult}, + {"has_only_phrase", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_only_phrase", dmy, []types.XValue{}, ERROR}, + + {"has_beginning", dmy, []types.XValue{xs("Must resist"), xs("must resist")}, result(xs("Must resist"))}, + {"has_beginning", dmy, []types.XValue{xs(" 2061212"), xs("206")}, result(xs("206"))}, + {"has_beginning", dmy, []types.XValue{xs(" world Too foo"), xs("world too")}, result(xs("world Too"))}, + {"has_beginning", dmy, []types.XValue{xs("but this world"), xs("this world")}, falseResult}, + {"has_beginning", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_beginning", dmy, []types.XValue{}, ERROR}, + + {"has_pattern", dmy, []types.XValue{xs("x"), xs(`<\w+>`)}, resultWithExtra(xs(""), types.NewXObject(map[string]types.XValue{"0": xs("")}))}, + {"has_pattern", dmy, []types.XValue{xs("x"), xs(`HTML`)}, resultWithExtra(xs("html"), types.NewXObject(map[string]types.XValue{"0": xs("html")}))}, + {"has_pattern", dmy, []types.XValue{xs("x"), xs(`(?-i)HTML`)}, falseResult}, + {"has_pattern", dmy, []types.XValue{xs("12345"), xs(`\A\d{5}\z`)}, resultWithExtra(xs("12345"), types.NewXObject(map[string]types.XValue{"0": xs("12345")}))}, + {"has_pattern", dmy, []types.XValue{xs("12345 "), xs(`\A\d{5}\z`)}, falseResult}, + {"has_pattern", dmy, []types.XValue{xs(" 12345"), xs(`\A\d{5}\z`)}, falseResult}, + {"has_pattern", dmy, []types.XValue{xs(`hi there 😀`), xs("[\U0001F600-\U0001F64F]")}, resultWithExtra(xs("😀"), types.NewXObject(map[string]types.XValue{"0": xs("😀")}))}, + {"has_pattern", dmy, []types.XValue{xs(`hi there`), xs("[\U0001F600-\U0001F64F]")}, falseResult}, + {"has_pattern", dmy, []types.XValue{xs(`hi there 😂`), xs("[😀-🙏]")}, resultWithExtra(xs("😂"), types.NewXObject(map[string]types.XValue{"0": xs("😂")}))}, + {"has_pattern", dmy, []types.XValue{xs("x"), xs(`[`)}, ERROR}, + {"has_pattern", dmy, []types.XValue{}, ERROR}, + + {"has_number", dmy, []types.XValue{xs("the number 10")}, result(xn("10"))}, + {"has_number", dmy, []types.XValue{xs("the number -10")}, result(xn("-10"))}, + {"has_number", dmy, []types.XValue{xs("1-15")}, result(xn("1"))}, + {"has_number", dmy, []types.XValue{xs("24ans")}, result(xn("24"))}, + {"has_number", dmy, []types.XValue{xs("J'AI 20ANS")}, result(xn("20"))}, + {"has_number", dmy, []types.XValue{xs("1,000,000")}, result(xn("1000000"))}, + {"has_number", dmy, []types.XValue{xs("the number 10")}, result(xn("10"))}, + {"has_number", dmy, []types.XValue{xs("O número é 500")}, result(xn("500"))}, + {"has_number", dmy, []types.XValue{xs("another is -12.51")}, result(xn("-12.51"))}, + {"has_number", dmy, []types.XValue{xs("hi.51")}, result(xn("51"))}, + {"has_number", dmy, []types.XValue{xs("hi .51")}, result(xn("0.51"))}, + {"has_number", dmy, []types.XValue{xs(".51")}, result(xn("0.51"))}, + {"has_number", dmy, []types.XValue{xs("١٢٣٤")}, result(xn("1234"))}, // Arabic + {"has_number", dmy, []types.XValue{xs("۱۲۳۴")}, result(xn("1234"))}, // Eastern Arabic + {"has_number", dmy, []types.XValue{xs("٠.٥")}, result(xn("0.5"))}, + {"has_number", dmy, []types.XValue{xs("nothing here")}, falseResult}, + {"has_number", dmy, []types.XValue{xs("lOO")}, falseResult}, // no longer do substitutions + {"has_number", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number", dmy, []types.XValue{}, ERROR}, + + {"has_number_lt", dmy, []types.XValue{xs("the number 10"), xs("11")}, result(xn("10"))}, + {"has_number_lt", dmy, []types.XValue{xs("another is -12.51"), xs("12")}, result(xn("-12.51"))}, + {"has_number_lt", dmy, []types.XValue{xs("١٠"), xs("11")}, result(xn("10"))}, + {"has_number_lt", dmy, []types.XValue{xs("nothing here"), xs("12")}, falseResult}, + {"has_number_lt", dmy, []types.XValue{xs("too big 15"), xs("12")}, falseResult}, + {"has_number_lt", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number_lt", dmy, []types.XValue{xs("but foo"), falseResult}, ERROR}, + {"has_number_lt", dmy, []types.XValue{nil, xs("but foo")}, ERROR}, + {"has_number_lt", dmy, []types.XValue{}, ERROR}, + + {"has_number_lte", dmy, []types.XValue{xs("the number 10"), xs("11")}, result(xn("10"))}, + {"has_number_lte", dmy, []types.XValue{xs("another is -12.51"), xs("12")}, result(xn("-12.51"))}, + {"has_number_lte", dmy, []types.XValue{xs("١٠"), xs("11")}, result(xn("10"))}, + {"has_number_lte", dmy, []types.XValue{xs("nothing here"), xs("12")}, falseResult}, + {"has_number_lte", dmy, []types.XValue{xs("too big 15"), xs("12")}, falseResult}, + {"has_number_lte", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number_lte", dmy, []types.XValue{}, ERROR}, + + {"has_number_eq", dmy, []types.XValue{xs("the number 10"), xs("10")}, result(xn("10"))}, + {"has_number_eq", dmy, []types.XValue{xs("another is -12.51"), xs("-12.51")}, result(xn("-12.51"))}, + {"has_number_eq", dmy, []types.XValue{xs("١٠"), xs("10")}, result(xn("10"))}, + {"has_number_eq", dmy, []types.XValue{xs("nothing here"), xs("12")}, falseResult}, + {"has_number_eq", dmy, []types.XValue{xs("wrong .51"), xs(".61")}, falseResult}, + {"has_number_eq", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number_eq", dmy, []types.XValue{}, ERROR}, + + {"has_number_gte", dmy, []types.XValue{xs("the number 10"), xs("9")}, result(xn("10"))}, + {"has_number_gte", dmy, []types.XValue{xs("another is -12.51"), xs("-13")}, result(xn("-12.51"))}, + {"has_number_gte", dmy, []types.XValue{xs("١٠"), xs("9")}, result(xn("10"))}, + {"has_number_gte", dmy, []types.XValue{xs("nothing here"), xs("12")}, falseResult}, + {"has_number_gte", dmy, []types.XValue{xs("too small -12"), xs("-11")}, falseResult}, + {"has_number_gte", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number_gte", dmy, []types.XValue{}, ERROR}, + + {"has_number_gt", dmy, []types.XValue{xs("the number 10"), xs("9")}, result(xn("10"))}, + {"has_number_gt", dmy, []types.XValue{xs("another is -12.51"), xs("-13")}, result(xn("-12.51"))}, + {"has_number_gt", dmy, []types.XValue{xs("١٠"), xs("9")}, result(xn("10"))}, + {"has_number_gt", dmy, []types.XValue{xs("nothing here"), xs("12")}, falseResult}, + {"has_number_gt", dmy, []types.XValue{xs("not great -12.51"), xs("-12.51")}, falseResult}, + {"has_number_gt", dmy, []types.XValue{xs("one"), xs("two"), xs("three")}, ERROR}, + {"has_number_gt", dmy, []types.XValue{}, ERROR}, + + {"has_number_between", dmy, []types.XValue{xs("the number 10"), xs("8"), xs("12")}, result(xn("10"))}, + {"has_number_between", dmy, []types.XValue{xs("24ans"), xn("20"), xn("24")}, result(xn("24"))}, + {"has_number_between", dmy, []types.XValue{xs("another is -12.51"), xs("-12.51"), xs("-10")}, result(xn("-12.51"))}, + {"has_number_between", dmy, []types.XValue{xs("١٠"), xs("8"), xs("12")}, result(xn("10"))}, + {"has_number_between", dmy, []types.XValue{xs("nothing here"), xs("10"), xs("15")}, falseResult}, + {"has_number_between", dmy, []types.XValue{xs("one"), xs("two")}, ERROR}, + {"has_number_between", dmy, []types.XValue{xs("but foo"), nil, xs("10")}, ERROR}, + {"has_number_between", dmy, []types.XValue{nil, xs("but foo"), xs("10")}, ERROR}, + {"has_number_between", dmy, []types.XValue{xs("a string"), xs("10"), xs("not number")}, ERROR}, + {"has_number_between", dmy, []types.XValue{}, ERROR}, + + {"has_date", dmy, []types.XValue{xs("last date was 1.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, + {"has_date", dmy, []types.XValue{xs("last date was 1.10.99")}, result(xd(time.Date(1999, 10, 1, 15, 24, 30, 123456000, kgl)))}, + {"has_date", dmy, []types.XValue{xs("this isn't a valid date 33.2.99")}, falseResult}, + {"has_date", dmy, []types.XValue{xs("no date at all")}, falseResult}, + {"has_date", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_date", dmy, []types.XValue{}, ERROR}, + + {"has_date_lt", dmy, []types.XValue{xs("last date was 1.10.2017"), xs("3.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, + {"has_date_lt", dmy, []types.XValue{xs("last date was 1.10.99"), xs("3.10.98")}, falseResult}, + {"has_date_lt", dmy, []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, + {"has_date_lt", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_date_lt", dmy, []types.XValue{xs("last date was 1.10.2017"), nil}, ERROR}, + {"has_date_lt", dmy, []types.XValue{nil, xs("but foo")}, ERROR}, + {"has_date_lt", dmy, []types.XValue{}, ERROR}, + + {"has_date_eq", dmy, []types.XValue{xs("last date was 1.10.2017"), xs("1.10.2017")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, + {"has_date_eq", dmy, []types.XValue{xs("last date was 1.10.99"), xs("3.10.98")}, falseResult}, + {"has_date_eq", dmy, []types.XValue{xs("2017-10-01T23:55:55.123456+02:00"), xs("1.10.2017")}, result(xd(time.Date(2017, 10, 1, 23, 55, 55, 123456000, kgl)))}, + {"has_date_eq", dmy, []types.XValue{xs("2017-10-01T23:55:55.123456+01:00"), xs("1.10.2017")}, falseResult}, // would have been 2017-10-02 in env timezone + {"has_date_eq", dmy, []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, + {"has_date_eq", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_date_eq", dmy, []types.XValue{}, ERROR}, + + {"has_date_gt", dmy, []types.XValue{xs("last date was 1.10.2017"), xs("3.10.2016")}, result(xd(time.Date(2017, 10, 1, 15, 24, 30, 123456000, kgl)))}, + {"has_date_gt", dmy, []types.XValue{xs("last date was 1.10.99"), xs("3.10.01")}, falseResult}, + {"has_date_gt", dmy, []types.XValue{xs("no date at all"), xs("3.10.98")}, falseResult}, + {"has_date_gt", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_date_gt", dmy, []types.XValue{}, ERROR}, + + {"has_time", dmy, []types.XValue{xs("last time was 10:30")}, result(xt(dates.NewTimeOfDay(10, 30, 0, 0)))}, + {"has_time", dmy, []types.XValue{xs("this isn't a valid time 59:77")}, falseResult}, + {"has_time", dmy, []types.XValue{xs("no time at all")}, falseResult}, + {"has_time", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_time", dmy, []types.XValue{}, ERROR}, + + {"has_email", dmy, []types.XValue{xs("my email is foo@bar.com.")}, result(xs("foo@bar.com"))}, + {"has_email", dmy, []types.XValue{xs("my email is ")}, result(xs("foo~$1+spam@bar-2.com"))}, + {"has_email", dmy, []types.XValue{xs("FOO@bar.whatzit")}, result(xs("FOO@bar.whatzit"))}, + {"has_email", dmy, []types.XValue{xs("FOO@βήτα.whatzit")}, result(xs("FOO@βήτα.whatzit"))}, + {"has_email", dmy, []types.XValue{xs("email is foo @ bar . com")}, falseResult}, + {"has_email", dmy, []types.XValue{xs("email is foo@bar")}, falseResult}, + {"has_email", dmy, []types.XValue{nil}, falseResult}, + {"has_email", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_email", dmy, []types.XValue{}, ERROR}, // more has_phone tests in TestHasPhone below - {"has_phone", []types.XValue{xs("my number is 0788123123"), xs("RW")}, result(xs("+250788123123"))}, - {"has_phone", []types.XValue{xs("my number is none of your business"), xs("US")}, falseResult}, - {"has_phone", []types.XValue{ERROR}, ERROR}, - {"has_phone", []types.XValue{xs("3245"), ERROR}, ERROR}, - {"has_phone", []types.XValue{xs("number"), nil}, falseResult}, - {"has_phone", []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, - {"has_phone", []types.XValue{}, ERROR}, + {"has_phone", dmy, []types.XValue{xs("my number is 0788123123"), xs("RW")}, result(xs("+250788123123"))}, + {"has_phone", dmy, []types.XValue{xs("my number is none of your business"), xs("US")}, falseResult}, + {"has_phone", dmy, []types.XValue{ERROR}, ERROR}, + {"has_phone", dmy, []types.XValue{xs("3245"), ERROR}, ERROR}, + {"has_phone", dmy, []types.XValue{xs("number"), nil}, falseResult}, + {"has_phone", dmy, []types.XValue{xs("too"), xs("many"), xs("args")}, ERROR}, + {"has_phone", dmy, []types.XValue{}, ERROR}, { "has_group", + dmy, []types.XValue{ xj(`[{"uuid": "group-uuid-1", "name": "Testers"}, {"uuid": "group-uuid-2", "name": "Customers"}]`), xs("group-uuid-2"), }, result(xj(`{"uuid": "group-uuid-2", "name": "Customers"}`)), }, - {"has_group", []types.XValue{xa(ERROR), xs("group-uuid-2")}, ERROR}, - {"has_group", []types.XValue{xa(), xs("group-uuid-1")}, falseResult}, - {"has_group", []types.XValue{ERROR, xs("group-uuid-1")}, ERROR}, - {"has_group", []types.XValue{xa(), ERROR}, ERROR}, - {"has_group", []types.XValue{}, ERROR}, - - {"has_state", []types.XValue{xs("Quebec")}, result(xs("Rwanda > Québec"))}, - {"has_state", []types.XValue{xs("Québec")}, result(xs("Rwanda > Québec"))}, - {"has_state", []types.XValue{xs("Je suis dans la province du Québec")}, result(xs("Rwanda > Québec"))}, - - {"has_state", []types.XValue{xs("Je suis dans la province de l'Île-de-France")}, result(xs("Rwanda > Île-de-France"))}, - - {"has_state", []types.XValue{xs("kigali city")}, result(xs("Rwanda > Kigali City"))}, - {"has_state", []types.XValue{xs("¡Kigali!")}, result(xs("Rwanda > Kigali City"))}, - - {"has_state", []types.XValue{xs("kigari")}, result(xs("Rwanda > Kigali City"))}, - {"has_state", []types.XValue{xs("تروو")}, result(xs("Rwanda > Paktika"))}, - {"has_state", []types.XValue{xs("غم ځپلې هلمند")}, falseResult}, - {"has_state", []types.XValue{xs("\u063a\u0645 \u0681\u067e\u0644\u06d0 \u0647\u0644\u0645\u0646\u062f")}, falseResult}, - {"has_state", []types.XValue{xs("xyz")}, falseResult}, - {"has_state", []types.XValue{ERROR}, ERROR}, - - {"has_district", []types.XValue{xs("Gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo"))}, - {"has_district", []types.XValue{xs("I live in gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo"))}, - {"has_district", []types.XValue{xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo"))}, - {"has_district", []types.XValue{xs("xyz"), xs("kigali")}, falseResult}, - {"has_district", []types.XValue{ERROR}, ERROR}, - - {"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("kigali"), xs("Gasabo")}, falseResult}, - {"has_ward", []types.XValue{ERROR}, ERROR}, + {"has_group", dmy, []types.XValue{xa(ERROR), xs("group-uuid-2")}, ERROR}, + {"has_group", dmy, []types.XValue{xa(), xs("group-uuid-1")}, falseResult}, + {"has_group", dmy, []types.XValue{ERROR, xs("group-uuid-1")}, ERROR}, + {"has_group", dmy, []types.XValue{xa(), ERROR}, ERROR}, + {"has_group", dmy, []types.XValue{}, ERROR}, + + {"has_state", dmy, []types.XValue{xs("Quebec")}, result(xs("Rwanda > Québec"))}, + {"has_state", dmy, []types.XValue{xs("Québec")}, result(xs("Rwanda > Québec"))}, + {"has_state", dmy, []types.XValue{xs("Je suis dans la province du Québec")}, result(xs("Rwanda > Québec"))}, + + {"has_state", dmy, []types.XValue{xs("Je suis dans la province de l'Île-de-France")}, result(xs("Rwanda > Île-de-France"))}, + + {"has_state", dmy, []types.XValue{xs("kigali city")}, result(xs("Rwanda > Kigali City"))}, + {"has_state", dmy, []types.XValue{xs("¡Kigali!")}, result(xs("Rwanda > Kigali City"))}, + + {"has_state", dmy, []types.XValue{xs("kigari")}, result(xs("Rwanda > Kigali City"))}, + {"has_state", dmy, []types.XValue{xs("تروو")}, result(xs("Rwanda > Paktika"))}, + {"has_state", dmy, []types.XValue{xs("غم ځپلې هلمند")}, falseResult}, + {"has_state", dmy, []types.XValue{xs("\u063a\u0645 \u0681\u067e\u0644\u06d0 \u0647\u0644\u0645\u0646\u062f")}, falseResult}, + {"has_state", dmy, []types.XValue{xs("xyz")}, falseResult}, + {"has_state", dmy, []types.XValue{ERROR}, ERROR}, + + {"has_district", dmy, []types.XValue{xs("Gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo"))}, + {"has_district", dmy, []types.XValue{xs("I live in gasabo"), xs("kigali")}, result(xs("Rwanda > Kigali City > Gasabo"))}, + {"has_district", dmy, []types.XValue{xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo"))}, + {"has_district", dmy, []types.XValue{xs("xyz"), xs("kigali")}, falseResult}, + {"has_district", dmy, []types.XValue{ERROR}, ERROR}, + + {"has_ward", dmy, []types.XValue{xs("Gisozi"), xs("kigali"), xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, + {"has_ward", dmy, []types.XValue{xs("I live in gisozi"), xs("kigali"), xs("Gasabo")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, + {"has_ward", dmy, []types.XValue{xs("Gisozi")}, result(xs("Rwanda > Kigali City > Gasabo > Gisozi"))}, + {"has_ward", dmy, []types.XValue{xs("xyz"), xs("kigali"), xs("Gasabo")}, falseResult}, + {"has_ward", dmy, []types.XValue{ERROR}, ERROR}, { "has_category", + dmy, []types.XValue{ xj(`{ "name": "Response 1", @@ -366,6 +384,7 @@ var testTests = []struct { }, { "has_category", + dmy, []types.XValue{ xj(`{ "name": "Response 1", @@ -381,6 +400,7 @@ var testTests = []struct { }, { "has_category", + dmy, []types.XValue{ xj(`{}`), // not a result xs("Chicken"), @@ -390,6 +410,7 @@ var testTests = []struct { { "has_intent", + dmy, []types.XValue{ xj(`{ "name": "Intention", @@ -424,6 +445,7 @@ var testTests = []struct { }, { "has_intent", + dmy, []types.XValue{ xj(`{}`), // not a result xs("book_flight"), @@ -431,10 +453,11 @@ var testTests = []struct { }, ERROR, }, - {"has_intent", []types.XValue{}, ERROR}, + {"has_intent", dmy, []types.XValue{}, ERROR}, { "has_top_intent", + dmy, []types.XValue{ xj(`{ "name": "Intention", @@ -469,6 +492,7 @@ var testTests = []struct { }, { "has_top_intent", + dmy, []types.XValue{ xj(`{ "name": "Intention", @@ -487,6 +511,7 @@ var testTests = []struct { }, { "has_top_intent", + dmy, []types.XValue{ xj(`{}`), // not a result xs("book_flight"), @@ -494,37 +519,30 @@ var testTests = []struct { }, ERROR, }, - {"has_top_intent", []types.XValue{}, ERROR}, + {"has_top_intent", dmy, []types.XValue{}, ERROR}, } func TestTests(t *testing.T) { dates.SetNowSource(dates.NewFixedNowSource(time.Date(2018, 4, 11, 13, 24, 30, 123456000, time.UTC))) defer dates.SetNowSource(dates.DefaultNowSource) - env := envs.NewBuilder(). - WithDateFormat(envs.DateFormatDayMonthYear). - WithTimeFormat(envs.TimeFormatHourMinuteSecond). - WithTimezone(kgl). - WithDefaultCountry(i18n.Country("RW")). - Build() - source, err := static.NewSource([]byte(assetsJSON)) require.NoError(t, err) - sa, err := engine.NewSessionAssets(env, source, nil) + sa, err := engine.NewSessionAssets(dmy, source, nil) require.NoError(t, err) contact := flows.NewEmptyContact(sa, "", i18n.NilLanguage, nil) - trigger := triggers.NewBuilder(env, assets.NewFlowReference("76f0a02f-3b75-4b86-9064-e9195e1b3a02", "Test"), contact).Manual().Build() - eng := engine.NewBuilder().Build() + for _, tc := range testTests { + trigger := triggers.NewBuilder(tc.env, assets.NewFlowReference("76f0a02f-3b75-4b86-9064-e9195e1b3a02", "Test"), contact).Manual().Build() + eng := engine.NewBuilder().Build() - session, _, err := eng.NewSession(sa, trigger) - require.NoError(t, err) + session, _, err := eng.NewSession(sa, trigger) + require.NoError(t, err) - env = session.MergedEnvironment() + env := session.MergedEnvironment() - for _, tc := range testTests { testID := fmt.Sprintf("%s(%#v)", tc.name, tc.args) testFunc, exists := cases.XTESTS[tc.name]