From 97ede2a428faf3a62ce0140e51ed591e261c09a1 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 25 Jan 2016 16:47:49 -0500 Subject: Updated serverside hashtag regex to ignore more punctuation around words --- model/search_params_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'model/search_params_test.go') diff --git a/model/search_params_test.go b/model/search_params_test.go index af4cbe595..59eb0a113 100644 --- a/model/search_params_test.go +++ b/model/search_params_test.go @@ -118,19 +118,19 @@ func TestParseSearchFlags(t *testing.T) { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("fruit: cherry")); len(words) != 2 || words[0] != "fruit:" || words[1] != "cherry" { + if words, flags := parseSearchFlags(splitWords("fruit: cherry")); len(words) != 2 || words[0] != "fruit" || words[1] != "cherry" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 0 { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("channel:")); len(words) != 1 || words[0] != "channel:" { + if words, flags := parseSearchFlags(splitWords("channel:")); len(words) != 1 || words[0] != "channel" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 0 { t.Fatalf("got incorrect flags %v", flags) } - if words, flags := parseSearchFlags(splitWords("channel: first in: second from:")); len(words) != 1 || words[0] != "from:" { + if words, flags := parseSearchFlags(splitWords("channel: first in: second from:")); len(words) != 1 || words[0] != "from" { t.Fatalf("got incorrect words %v", words) } else if len(flags) != 2 || flags[0][0] != "channel" || flags[0][1] != "first" || flags[1][0] != "in" || flags[1][1] != "second" { t.Fatalf("got incorrect flags %v", flags) @@ -212,4 +212,8 @@ func TestParseSearchParams(t *testing.T) { if sp := ParseSearchParams("testing in:channel from:someone"); len(sp) != 1 || sp[0].Terms != "testing" || len(sp[0].InChannels) != 1 || sp[0].InChannels[0] != "channel" || len(sp[0].FromUsers) != 1 || sp[0].FromUsers[0] != "someone" { t.Fatalf("Incorrect output from parse search params: %v", sp[0]) } + + if sp := ParseSearchParams("##hashtag +#plus+"); len(sp) != 1 || sp[0].Terms != "#hashtag #plus" || sp[0].IsHashtag != true || len(sp[0].InChannels) != 0 || len(sp[0].FromUsers) != 0 { + t.Fatalf("Incorrect output from parse search params: %v", sp[0]) + } } -- cgit v1.2.3-1-g7c22