1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2// See LICENSE.txt for license information.
3
4package model
5
6import (
7	"testing"
8	"time"
9
10	"github.com/stretchr/testify/assert"
11	"github.com/stretchr/testify/require"
12)
13
14func TestSplitWords(t *testing.T) {
15	for _, testCase := range []struct {
16		Name  string
17		Input string
18
19		Output []string
20	}{
21		{
22			Name:   "string is empty, output should be empty",
23			Input:  "",
24			Output: []string{},
25		},
26		{
27			Name:   "string is only spaces, output should be empty",
28			Input:  "      ",
29			Output: []string{},
30		},
31		{
32			Name:   "string is a single word, output should be one word length",
33			Input:  "word",
34			Output: []string{"word"},
35		},
36		{
37			Name:   "string has a single \" character, output should be two words",
38			Input:  "wo\"rd",
39			Output: []string{"wo", "\"rd"},
40		},
41		{
42			Name:   "string has multiple \" characters, output should be two words",
43			Input:  "wo\"rd\"",
44			Output: []string{"wo", "\"rd\""},
45		},
46		{
47			Name:   "string has multiple \" characters and a -, output should be two words",
48			Input:  "wo-\"rd\"",
49			Output: []string{"wo", "-\"rd\""},
50		},
51		{
52			Name:   "string has multiple words, output should be 3 words",
53			Input:  "word1 word2 word3",
54			Output: []string{"word1", "word2", "word3"},
55		},
56		{
57			Name:   "string has multiple words with a \" in the middle, output should be 3 words",
58			Input:  "word1 \"word2 word3",
59			Output: []string{"word1", "\"word2", "word3"},
60		},
61		{
62			Name:   "string has multiple words with a \" at the start, output should be 3 words",
63			Input:  "\"word1 word2 word3",
64			Output: []string{"\"word1", "word2", "word3"},
65		},
66		{
67			Name:   "string has multiple words with a \" at the end, output should be 3 words and a \"",
68			Input:  "word1 word2 word3\"",
69			Output: []string{"word1", "word2", "word3", "\""},
70		},
71		{
72			Name:   "string has multiple words with # as a prefix, output should be 3 words and prefixes kept",
73			Input:  "word1 #word2 ##word3",
74			Output: []string{"word1", "#word2", "##word3"},
75		},
76		{
77			Name:   "string has multiple words with multiple space between them, output should still be 3 words",
78			Input:  "   word1 word2      word3",
79			Output: []string{"word1", "word2", "word3"},
80		},
81		{
82			Name:   "string has a quoted word, output should also be quoted",
83			Input:  "\"quoted\"",
84			Output: []string{"\"quoted\""},
85		},
86		{
87			Name:   "string has a quoted word with a - prefix, output should also be quoted with the same prefix",
88			Input:  "-\"quoted\"",
89			Output: []string{"-\"quoted\""},
90		},
91		{
92			Name:   "string has multiple quoted words, output should not be splitted and quotes should be kept",
93			Input:  "\"quoted multiple words\"",
94			Output: []string{"\"quoted multiple words\""},
95		},
96		{
97			Name:   "string has a mix of qouted words and non quoted words, output should contain 5 entries, quoted words should not be split",
98			Input:  "some stuff \"quoted multiple words\" more stuff",
99			Output: []string{"some", "stuff", "\"quoted multiple words\"", "more", "stuff"},
100		},
101		{
102			Name:   "string has a mix of qouted words with a - prefix and non quoted words, output should contain 5 entries, quoted words should not be split, - should be kept",
103			Input:  "some stuff -\"quoted multiple words\" more stuff",
104			Output: []string{"some", "stuff", "-\"quoted multiple words\"", "more", "stuff"},
105		},
106		{
107			Name:   "string has a mix of multiple qouted words with a - prefix and non quoted words including a # character, output should contain 5 entries, quoted words should not be split, # and - should be kept",
108			Input:  "some \"stuff\" \"quoted multiple words\" #some \"more stuff\"",
109			Output: []string{"some", "\"stuff\"", "\"quoted multiple words\"", "#some", "\"more stuff\""},
110		},
111	} {
112		t.Run(testCase.Name, func(t *testing.T) {
113			assert.Equal(t, testCase.Output, splitWords(testCase.Input))
114		})
115	}
116
117}
118
119func TestParseSearchFlags2(t *testing.T) {
120	for _, testCase := range []struct {
121		Name  string
122		Input string
123
124		Words []searchWord
125		Flags []flag
126	}{
127		{
128			Name:  "string is empty",
129			Input: "",
130			Words: []searchWord{},
131			Flags: []flag{},
132		},
133		{
134			Name:  "string is a single word",
135			Input: "word",
136			Words: []searchWord{
137				{
138					value:   "word",
139					exclude: false,
140				},
141			},
142			Flags: []flag{},
143		},
144		{
145			Name:  "string is a single word with a - prefix",
146			Input: "-word",
147			Words: []searchWord{
148				{
149					value:   "word",
150					exclude: true,
151				},
152			},
153			Flags: []flag{},
154		},
155		{
156			Name:  "string is multiple words all with - prefix",
157			Input: "-apple -banana -cherry",
158			Words: []searchWord{
159				{
160					value:   "apple",
161					exclude: true,
162				},
163				{
164					value:   "banana",
165					exclude: true,
166				},
167				{
168					value:   "cherry",
169					exclude: true,
170				},
171			},
172			Flags: []flag{},
173		},
174		{
175			Name:  "string is multiple words with a single - prefix",
176			Input: "apple -banana cherry",
177			Words: []searchWord{
178				{
179					value:   "apple",
180					exclude: false,
181				},
182				{
183					value:   "banana",
184					exclude: true,
185				},
186				{
187					value:   "cherry",
188					exclude: false,
189				},
190			},
191			Flags: []flag{},
192		},
193		{
194			Name:  "string is multiple words containing a flag",
195			Input: "apple banana from:chan",
196			Words: []searchWord{
197				{
198					value:   "apple",
199					exclude: false,
200				},
201				{
202					value:   "banana",
203					exclude: false,
204				},
205			},
206			Flags: []flag{
207				{
208					name:  "from",
209					value: "chan",
210				},
211			},
212		},
213		{
214			Name:  "string is multiple words containing a flag and a - prefix",
215			Input: "apple -banana from:chan",
216			Words: []searchWord{
217				{
218					value:   "apple",
219					exclude: false,
220				},
221				{
222					value:   "banana",
223					exclude: true,
224				},
225			},
226			Flags: []flag{
227				{
228					name:  "from",
229					value: "chan",
230				},
231			},
232		},
233		{
234			Name:  "string is multiple words containing a flag and multiple - prefixes",
235			Input: "-apple -banana from:chan",
236			Words: []searchWord{
237				{
238					value:   "apple",
239					exclude: true,
240				},
241				{
242					value:   "banana",
243					exclude: true,
244				},
245			},
246			Flags: []flag{
247				{
248					name:  "from",
249					value: "chan",
250				},
251			},
252		},
253		{
254			Name:  "string is multiple words containing a flag and multiple # prefixes",
255			Input: "#apple #banana from:chan",
256			Words: []searchWord{
257				{
258					value:   "#apple",
259					exclude: false,
260				},
261				{
262					value:   "#banana",
263					exclude: false,
264				},
265			},
266			Flags: []flag{
267				{
268					name:  "from",
269					value: "chan",
270				},
271			},
272		},
273		{
274			Name:  "string is multiple words containing a flag with a single - and multiple # prefixes",
275			Input: "-#apple #banana from:chan",
276			Words: []searchWord{
277				{
278					value:   "#apple",
279					exclude: true,
280				},
281				{
282					value:   "#banana",
283					exclude: false,
284				},
285			},
286			Flags: []flag{
287				{
288					name:  "from",
289					value: "chan",
290				},
291			},
292		},
293		{
294			Name:  "string is multiple words containing a flag prefixed with - and multiple # prefixes",
295			Input: "#apple #banana -from:chan",
296			Words: []searchWord{
297				{
298					value:   "#apple",
299					exclude: false,
300				},
301				{
302					value:   "#banana",
303					exclude: false,
304				},
305			},
306			Flags: []flag{
307				{
308					name:    "from",
309					value:   "chan",
310					exclude: true,
311				},
312			},
313		},
314		{
315			Name:  "string is multiple words containing a flag prefixed with multiple - and multiple # prefixes",
316			Input: "-#apple -#banana -from:chan",
317			Words: []searchWord{
318				{
319					value:   "#apple",
320					exclude: true,
321				},
322				{
323					value:   "#banana",
324					exclude: true,
325				},
326			},
327			Flags: []flag{
328				{
329					name:    "from",
330					value:   "chan",
331					exclude: true,
332				},
333			},
334		},
335		{
336			Name:  "string is multiple words containing a flag with a space",
337			Input: "apple banana from: chan",
338			Words: []searchWord{
339				{
340					value:   "apple",
341					exclude: false,
342				},
343				{
344					value:   "banana",
345					exclude: false,
346				},
347			},
348			Flags: []flag{
349				{
350					name:  "from",
351					value: "chan",
352				},
353			},
354		},
355		{
356			Name:  "string is multiple words containing a in flag with a space",
357			Input: "apple banana in: chan",
358			Words: []searchWord{
359				{
360					value:   "apple",
361					exclude: false,
362				},
363				{
364					value:   "banana",
365					exclude: false,
366				},
367			},
368			Flags: []flag{
369				{
370					name:  "in",
371					value: "chan",
372				},
373			},
374		},
375		{
376			Name:  "string is multiple words containing a channel flag with a space",
377			Input: "apple banana channel: chan",
378			Words: []searchWord{
379				{
380					value:   "apple",
381					exclude: false,
382				},
383				{
384					value:   "banana",
385					exclude: false,
386				},
387			},
388			Flags: []flag{
389				{
390					name:  "channel",
391					value: "chan",
392				},
393			},
394		},
395		{
396			Name:  "string with a non-floag followed by :",
397			Input: "fruit: cherry",
398			Words: []searchWord{
399				{
400					value:   "fruit",
401					exclude: false,
402				},
403				{
404					value:   "cherry",
405					exclude: false,
406				},
407			},
408			Flags: []flag{},
409		},
410		{
411			Name:  "string with the a flag but without the value for that flag should be threaded as a word",
412			Input: "channel:",
413			Words: []searchWord{
414				{
415					value:   "channel",
416					exclude: false,
417				},
418			},
419			Flags: []flag{},
420		},
421		{
422			Name:  "string is a single flag which results in a single flag",
423			Input: "channel:first",
424			Words: []searchWord{},
425			Flags: []flag{
426				{
427					name:  "channel",
428					value: "first",
429				},
430			},
431		},
432		{
433			Name:  "single flag with - which results in a excluded flag",
434			Input: "-channel:first",
435			Words: []searchWord{},
436			Flags: []flag{
437				{
438					name:    "channel",
439					value:   "first",
440					exclude: true,
441				},
442			},
443		},
444		{
445			Name:  "string is multiple flags which results in multiple unexcluded flags and a single search word",
446			Input: "channel: first in: second from:",
447			Words: []searchWord{
448				{
449					value:   "from",
450					exclude: false,
451				},
452			},
453			Flags: []flag{
454				{
455					name:    "channel",
456					value:   "first",
457					exclude: false,
458				},
459				{
460					name:    "in",
461					value:   "second",
462					exclude: false,
463				},
464			},
465		},
466		{
467			Name:  "string is multiple flags which results in multiple unexcluded and excluded flags and a single search word",
468			Input: "channel: first -in: second from:",
469			Words: []searchWord{
470				{
471					value:   "from",
472					exclude: false,
473				},
474			},
475			Flags: []flag{
476				{
477					name:    "channel",
478					value:   "first",
479					exclude: false,
480				},
481				{
482					name:    "in",
483					value:   "second",
484					exclude: true,
485				},
486			},
487		},
488		{
489			Name:  "string is multiple flags which results in multiple excluded and unexcluded flags and a single search word",
490			Input: "-channel: first in: second from:",
491			Words: []searchWord{
492				{
493					value:   "from",
494					exclude: false,
495				},
496			},
497			Flags: []flag{
498				{
499					name:    "channel",
500					value:   "first",
501					exclude: true,
502				},
503				{
504					name:    "in",
505					value:   "second",
506					exclude: false,
507				},
508			},
509		},
510		{
511			Name:  "string is four flags which results four unexcluded flags",
512			Input: "channel: first channel: second from: third from: fourth",
513			Words: []searchWord{},
514			Flags: []flag{
515				{
516					name:    "channel",
517					value:   "first",
518					exclude: false,
519				},
520				{
521					name:    "channel",
522					value:   "second",
523					exclude: false,
524				},
525				{
526					name:    "from",
527					value:   "third",
528					exclude: false,
529				},
530				{
531					name:    "from",
532					value:   "fourth",
533					exclude: false,
534				},
535			},
536		},
537		{
538			Name:  "string is a single quoted flag which results in a single search word which is quoted",
539			Input: "\"quoted\"",
540			Words: []searchWord{
541				{
542					value:   "\"quoted\"",
543					exclude: false,
544				},
545			},
546			Flags: []flag{},
547		},
548		{
549			Name:  "string is a single quoted flag prefixed with a - which results in a single search word which is quoted",
550			Input: "\"-quoted\"",
551			Words: []searchWord{
552				{
553					value:   "\"-quoted\"",
554					exclude: false,
555				},
556			},
557			Flags: []flag{},
558		},
559		{
560			Name:  "string is a single quoted flag prefixed with a - which results in a single search word which is quoted and exported",
561			Input: "-\"quoted\"",
562			Words: []searchWord{
563				{
564					value:   "\"quoted\"",
565					exclude: true,
566				},
567			},
568			Flags: []flag{},
569		},
570		{
571			Name:  "string is multiple quoted flags which results in a single search word which is quoted and unexported",
572			Input: "\"quoted multiple words\"",
573			Words: []searchWord{
574				{
575					value:   "\"quoted multiple words\"",
576					exclude: false,
577				},
578			},
579			Flags: []flag{},
580		},
581		{
582			Name:  "string is multiple quoted flags prefixed with - which results in a single search word which is quoted and unexported",
583			Input: "\"quoted -multiple words\"",
584			Words: []searchWord{
585				{
586					value:   "\"quoted -multiple words\"",
587					exclude: false,
588				},
589			},
590			Flags: []flag{},
591		},
592		{
593			Name:  "string is multiple quoted flags and unquoted words",
594			Input: "some \"stuff\" \"quoted multiple words\" some \"more stuff\"",
595			Words: []searchWord{
596				{
597					value:   "some",
598					exclude: false,
599				},
600				{
601					value:   "\"stuff\"",
602					exclude: false,
603				},
604				{
605					value:   "\"quoted multiple words\"",
606					exclude: false,
607				},
608				{
609					value:   "some",
610					exclude: false,
611				},
612				{
613					value:   "\"more stuff\"",
614					exclude: false,
615				},
616			},
617			Flags: []flag{},
618		},
619		{
620			Name:  "string is multiple quoted flags and unquoted words some being prefixed with -",
621			Input: "some -\"stuff\" \"quoted multiple words\" some -\"more stuff\"",
622			Words: []searchWord{
623				{
624					value:   "some",
625					exclude: false,
626				},
627				{
628					value:   "\"stuff\"",
629					exclude: true,
630				},
631				{
632					value:   "\"quoted multiple words\"",
633					exclude: false,
634				},
635				{
636					value:   "some",
637					exclude: false,
638				},
639				{
640					value:   "\"more stuff\"",
641					exclude: true,
642				},
643			},
644			Flags: []flag{},
645		},
646		{
647			Name:  "string is multiple quoted flags and unquoted words some being flags",
648			Input: "some in:here \"stuff\" \"quoted multiple words\" from:someone \"more stuff\"",
649			Words: []searchWord{
650				{
651					value:   "some",
652					exclude: false,
653				},
654				{
655					value:   "\"stuff\"",
656					exclude: false,
657				},
658				{
659					value:   "\"quoted multiple words\"",
660					exclude: false,
661				},
662				{
663					value:   "\"more stuff\"",
664					exclude: false,
665				},
666			},
667			Flags: []flag{
668				{
669					name:    "in",
670					value:   "here",
671					exclude: false,
672				},
673				{
674					name:    "from",
675					value:   "someone",
676					exclude: false,
677				},
678			},
679		},
680		{
681			Name:  "string is a single flag with multiple -",
682			Input: "after:2018-1-1",
683			Words: []searchWord{},
684			Flags: []flag{
685				{
686					name:    "after",
687					value:   "2018-1-1",
688					exclude: false,
689				},
690			},
691		},
692		{
693			Name:  "string is a single flag with multiple - prefixed with a -",
694			Input: "-after:2018-1-1",
695			Words: []searchWord{},
696			Flags: []flag{
697				{
698					name:    "after",
699					value:   "2018-1-1",
700					exclude: true,
701				},
702			},
703		},
704		{
705			Name:  "string is a single flag with multiple - prefixed with two words",
706			Input: "apple banana before:2018-1-1",
707			Words: []searchWord{
708				{
709					value:   "apple",
710					exclude: false,
711				},
712				{
713					value:   "banana",
714					exclude: false,
715				},
716			},
717			Flags: []flag{
718				{
719					name:    "before",
720					value:   "2018-1-1",
721					exclude: false,
722				},
723			},
724		},
725		{
726			Name:  "string is a single before flag with multiple - prefixed with - and two words",
727			Input: "apple banana -before:2018-1-1",
728			Words: []searchWord{
729				{
730					value:   "apple",
731					exclude: false,
732				},
733				{
734					value:   "banana",
735					exclude: false,
736				},
737			},
738			Flags: []flag{
739				{
740					name:    "before",
741					value:   "2018-1-1",
742					exclude: true,
743				},
744			},
745		},
746		{
747			Name:  "string is multiple before/after flags with two words before",
748			Input: "apple banana after:2018-1-1 before:2018-1-10",
749			Words: []searchWord{
750				{
751					value:   "apple",
752					exclude: false,
753				},
754				{
755					value:   "banana",
756					exclude: false,
757				},
758			},
759			Flags: []flag{
760				{
761					name:    "after",
762					value:   "2018-1-1",
763					exclude: false,
764				},
765				{
766					name:    "before",
767					value:   "2018-1-10",
768					exclude: false,
769				},
770			},
771		},
772		{
773			Name:  "string is multiple before/after flags prefixed with - with two words before",
774			Input: "apple banana -after:2018-1-1 -before:2018-1-10",
775			Words: []searchWord{
776				{
777					value:   "apple",
778					exclude: false,
779				},
780				{
781					value:   "banana",
782					exclude: false,
783				},
784			},
785			Flags: []flag{
786				{
787					name:    "after",
788					value:   "2018-1-1",
789					exclude: true,
790				},
791				{
792					name:    "before",
793					value:   "2018-1-10",
794					exclude: true,
795				},
796			},
797		},
798		{
799			Name:  "string is a single after flag with two words before which are prefixed with #",
800			Input: "#apple #banana after:2018-1-1",
801			Words: []searchWord{
802				{
803					value:   "#apple",
804					exclude: false,
805				},
806				{
807					value:   "#banana",
808					exclude: false,
809				},
810			},
811			Flags: []flag{
812				{
813					name:    "after",
814					value:   "2018-1-1",
815					exclude: false,
816				},
817			},
818		},
819		{
820			Name:  "string is a single after flag with two words before which are prefixed with #",
821			Input: "#apple #banana before:2018-1-1",
822			Words: []searchWord{
823				{
824					value:   "#apple",
825					exclude: false,
826				},
827				{
828					value:   "#banana",
829					exclude: false,
830				},
831			},
832			Flags: []flag{
833				{
834					name:    "before",
835					value:   "2018-1-1",
836					exclude: false,
837				},
838			},
839		},
840		{
841			Name:  "string is two after and before flags with two words before which are prefixed with #",
842			Input: "#apple #banana after:2018-1-1 before:2018-1-10",
843			Words: []searchWord{
844				{
845					value:   "#apple",
846					exclude: false,
847				},
848				{
849					value:   "#banana",
850					exclude: false,
851				},
852			},
853			Flags: []flag{
854				{
855					name:    "after",
856					value:   "2018-1-1",
857					exclude: false,
858				},
859				{
860					name:    "before",
861					value:   "2018-1-10",
862					exclude: false,
863				},
864			},
865		},
866		{
867			Name:  "string is a single after flag with two words before",
868			Input: "apple banana after: 2018-1-1",
869			Words: []searchWord{
870				{
871					value:   "apple",
872					exclude: false,
873				},
874				{
875					value:   "banana",
876					exclude: false,
877				},
878			},
879			Flags: []flag{
880				{
881					name:    "after",
882					value:   "2018-1-1",
883					exclude: false,
884				},
885			},
886		},
887		{
888			Name:  "string is a single before flag with two words before",
889			Input: "apple banana before: 2018-1-1",
890			Words: []searchWord{
891				{
892					value:   "apple",
893					exclude: false,
894				},
895				{
896					value:   "banana",
897					exclude: false,
898				},
899			},
900			Flags: []flag{
901				{
902					name:    "before",
903					value:   "2018-1-1",
904					exclude: false,
905				},
906			},
907		},
908		{
909			Name:  "string is two after and before flags with two words before",
910			Input: "apple banana after: 2018-1-1 before: 2018-1-10",
911			Words: []searchWord{
912				{
913					value:   "apple",
914					exclude: false,
915				},
916				{
917					value:   "banana",
918					exclude: false,
919				},
920			},
921			Flags: []flag{
922				{
923					name:    "after",
924					value:   "2018-1-1",
925					exclude: false,
926				},
927				{
928					name:    "before",
929					value:   "2018-1-10",
930					exclude: false,
931				},
932			},
933		},
934		{
935			Name:  "string is two after and before flags with two words before and a single after",
936			Input: "apple banana after: 2018-1-1 before: 2018-1-10 #fruit",
937			Words: []searchWord{
938				{
939					value:   "apple",
940					exclude: false,
941				},
942				{
943					value:   "banana",
944					exclude: false,
945				},
946				{
947					value:   "#fruit",
948					exclude: false,
949				},
950			},
951			Flags: []flag{
952				{
953					name:    "after",
954					value:   "2018-1-1",
955					exclude: false,
956				},
957				{
958					name:    "before",
959					value:   "2018-1-10",
960					exclude: false,
961				},
962			},
963		},
964		{
965			Name:  "string is one after flag with one word before",
966			Input: "test after:2018-7-1",
967			Words: []searchWord{
968				{
969					value:   "test",
970					exclude: false,
971				},
972			},
973			Flags: []flag{
974				{
975					name:    "after",
976					value:   "2018-7-1",
977					exclude: false,
978				},
979			},
980		},
981		{
982			Name:  "string is one on flag with one word before",
983			Input: "test on:2018-7-1",
984			Words: []searchWord{
985				{
986					value:   "test",
987					exclude: false,
988				},
989			},
990			Flags: []flag{
991				{
992					name:    "on",
993					value:   "2018-7-1",
994					exclude: false,
995				},
996			},
997		},
998		{
999			Name:  "string is one excluded on flag with one word after",
1000			Input: "-on:2018-7-1 test",
1001			Words: []searchWord{
1002				{
1003					value:   "test",
1004					exclude: false,
1005				},
1006			},
1007			Flags: []flag{
1008				{
1009					name:    "on",
1010					value:   "2018-7-1",
1011					exclude: true,
1012				},
1013			},
1014		},
1015	} {
1016		t.Run(testCase.Name, func(t *testing.T) {
1017			words, flags := parseSearchFlags(splitWords(testCase.Input))
1018			require.Equal(t, testCase.Words, words)
1019			require.Equal(t, testCase.Flags, flags)
1020		})
1021	}
1022}
1023
1024func TestParseSearchParams(t *testing.T) {
1025	for _, testCase := range []struct {
1026		Name  string
1027		Input string
1028
1029		Output []*SearchParams
1030	}{
1031		{
1032			Name:   "input is empty should result in no params",
1033			Input:  "",
1034			Output: []*SearchParams{},
1035		},
1036		{
1037			Name:   "input is only spaces should result in no params",
1038			Input:  "   ",
1039			Output: []*SearchParams{},
1040		},
1041		{
1042			Name:  "input is two words should result in one param",
1043			Input: "words words",
1044			Output: []*SearchParams{
1045				{
1046					Terms:              "words words",
1047					ExcludedTerms:      "",
1048					IsHashtag:          false,
1049					InChannels:         []string{},
1050					ExcludedChannels:   []string{},
1051					FromUsers:          []string{},
1052					ExcludedUsers:      []string{},
1053					Extensions:         []string{},
1054					ExcludedExtensions: []string{},
1055				},
1056			},
1057		},
1058		{
1059			Name:  "input is two words should result in one param with two excluded terms",
1060			Input: "-word1 -word2",
1061			Output: []*SearchParams{
1062				{
1063					Terms:              "",
1064					ExcludedTerms:      "word1 word2",
1065					IsHashtag:          false,
1066					InChannels:         []string{},
1067					ExcludedChannels:   []string{},
1068					FromUsers:          []string{},
1069					ExcludedUsers:      []string{},
1070					Extensions:         []string{},
1071					ExcludedExtensions: []string{},
1072				},
1073			},
1074		},
1075		{
1076			Name:  "input is two quoted words should result in one term",
1077			Input: "\"my stuff\"",
1078			Output: []*SearchParams{
1079				{
1080					Terms:              "\"my stuff\"",
1081					ExcludedTerms:      "",
1082					IsHashtag:          false,
1083					InChannels:         []string{},
1084					ExcludedChannels:   []string{},
1085					FromUsers:          []string{},
1086					ExcludedUsers:      []string{},
1087					Extensions:         []string{},
1088					ExcludedExtensions: []string{},
1089				},
1090			},
1091		},
1092		{
1093			Name:  "input is two quoted words should result in one excluded term",
1094			Input: "-\"my stuff\"",
1095			Output: []*SearchParams{
1096				{
1097					Terms:              "",
1098					ExcludedTerms:      "\"my stuff\"",
1099					IsHashtag:          false,
1100					InChannels:         []string{},
1101					ExcludedChannels:   []string{},
1102					FromUsers:          []string{},
1103					ExcludedUsers:      []string{},
1104					Extensions:         []string{},
1105					ExcludedExtensions: []string{},
1106				},
1107			},
1108		},
1109		{
1110			Name:  "input is two words prefixed with hashtags should result in one term",
1111			Input: "#words #words",
1112			Output: []*SearchParams{
1113				{
1114					Terms:              "#words #words",
1115					ExcludedTerms:      "",
1116					IsHashtag:          true,
1117					InChannels:         []string{},
1118					ExcludedChannels:   []string{},
1119					FromUsers:          []string{},
1120					ExcludedUsers:      []string{},
1121					Extensions:         []string{},
1122					ExcludedExtensions: []string{},
1123				},
1124			},
1125		},
1126		{
1127			Name:  "input is two words one is prefixed with a hashtag should result in two terms",
1128			Input: "#words words",
1129			Output: []*SearchParams{
1130				{
1131					Terms:              "words",
1132					ExcludedTerms:      "",
1133					IsHashtag:          false,
1134					InChannels:         []string{},
1135					ExcludedChannels:   []string{},
1136					FromUsers:          []string{},
1137					ExcludedUsers:      []string{},
1138					Extensions:         []string{},
1139					ExcludedExtensions: []string{},
1140				},
1141				{
1142					Terms:              "#words",
1143					ExcludedTerms:      "",
1144					IsHashtag:          true,
1145					InChannels:         []string{},
1146					ExcludedChannels:   []string{},
1147					FromUsers:          []string{},
1148					ExcludedUsers:      []string{},
1149					Extensions:         []string{},
1150					ExcludedExtensions: []string{},
1151				},
1152			},
1153		},
1154		{
1155			Name:  "input is one word prefixed with hashtag and a dash should result in one excluded term",
1156			Input: "-#hashtag",
1157			Output: []*SearchParams{
1158				{
1159					Terms:              "",
1160					ExcludedTerms:      "#hashtag",
1161					IsHashtag:          true,
1162					InChannels:         []string{},
1163					ExcludedChannels:   []string{},
1164					FromUsers:          []string{},
1165					ExcludedUsers:      []string{},
1166					Extensions:         []string{},
1167					ExcludedExtensions: []string{},
1168				},
1169			},
1170		},
1171		{
1172			Name:  "input is two words prefixed with hashtags and dashes should result in excluded term",
1173			Input: "-#hashtag1 -#hashtag2",
1174			Output: []*SearchParams{
1175				{
1176					Terms:              "",
1177					ExcludedTerms:      "#hashtag1 #hashtag2",
1178					IsHashtag:          true,
1179					InChannels:         []string{},
1180					ExcludedChannels:   []string{},
1181					FromUsers:          []string{},
1182					ExcludedUsers:      []string{},
1183					Extensions:         []string{},
1184					ExcludedExtensions: []string{},
1185				},
1186			},
1187		},
1188		{
1189			Name:  "input is two words prefixed with hashtags and one dash should result in excluded and nonexcluded term",
1190			Input: "#hashtag1 -#hashtag2",
1191			Output: []*SearchParams{
1192				{
1193					Terms:              "#hashtag1",
1194					ExcludedTerms:      "#hashtag2",
1195					IsHashtag:          true,
1196					InChannels:         []string{},
1197					ExcludedChannels:   []string{},
1198					FromUsers:          []string{},
1199					ExcludedUsers:      []string{},
1200					Extensions:         []string{},
1201					ExcludedExtensions: []string{},
1202				},
1203			},
1204		},
1205		{
1206			Name:  "input is 4 words prefixed with hashtags and a dash should result in excluded and nonexcluded multiple SearchParams",
1207			Input: "word1 #hashtag1 -#hashtag2 -word2",
1208			Output: []*SearchParams{
1209				{
1210					Terms:              "word1",
1211					ExcludedTerms:      "word2",
1212					IsHashtag:          false,
1213					InChannels:         []string{},
1214					ExcludedChannels:   []string{},
1215					FromUsers:          []string{},
1216					ExcludedUsers:      []string{},
1217					Extensions:         []string{},
1218					ExcludedExtensions: []string{},
1219				},
1220				{
1221					Terms:              "#hashtag1",
1222					ExcludedTerms:      "#hashtag2",
1223					IsHashtag:          true,
1224					InChannels:         []string{},
1225					ExcludedChannels:   []string{},
1226					FromUsers:          []string{},
1227					ExcludedUsers:      []string{},
1228					Extensions:         []string{},
1229					ExcludedExtensions: []string{},
1230				},
1231			},
1232		},
1233		{
1234			Name:  "input is two words separated with : and should result in a single InChannel",
1235			Input: "in:channel",
1236			Output: []*SearchParams{
1237				{
1238					Terms:              "",
1239					ExcludedTerms:      "",
1240					IsHashtag:          false,
1241					InChannels:         []string{"channel"},
1242					ExcludedChannels:   []string{},
1243					FromUsers:          []string{},
1244					ExcludedUsers:      []string{},
1245					Extensions:         []string{},
1246					ExcludedExtensions: []string{},
1247				},
1248			},
1249		},
1250		{
1251			Name:  "input is two words separated with :, prefied with - and should result in a single ExcludedChannel",
1252			Input: "-in:channel",
1253			Output: []*SearchParams{
1254				{
1255					Terms:              "",
1256					ExcludedTerms:      "",
1257					IsHashtag:          false,
1258					InChannels:         []string{},
1259					ExcludedChannels:   []string{"channel"},
1260					FromUsers:          []string{},
1261					ExcludedUsers:      []string{},
1262					Extensions:         []string{},
1263					ExcludedExtensions: []string{},
1264				},
1265			},
1266		},
1267		{
1268			Name:  "input is two words separated with : with a prefixed word should result in a single InChannel and a term",
1269			Input: "testing in:channel",
1270			Output: []*SearchParams{
1271				{
1272					Terms:              "testing",
1273					ExcludedTerms:      "",
1274					IsHashtag:          false,
1275					InChannels:         []string{"channel"},
1276					ExcludedChannels:   []string{},
1277					FromUsers:          []string{},
1278					ExcludedUsers:      []string{},
1279					Extensions:         []string{},
1280					ExcludedExtensions: []string{},
1281				},
1282			},
1283		},
1284		{
1285			Name:  "input is two words separated with : with a prefixed word should result in a single ExcludedChannel and a term",
1286			Input: "testing -in:channel",
1287			Output: []*SearchParams{
1288				{
1289					Terms:              "testing",
1290					ExcludedTerms:      "",
1291					IsHashtag:          false,
1292					InChannels:         []string{},
1293					ExcludedChannels:   []string{"channel"},
1294					FromUsers:          []string{},
1295					ExcludedUsers:      []string{},
1296					Extensions:         []string{},
1297					ExcludedExtensions: []string{},
1298				},
1299			},
1300		},
1301		{
1302			Name:  "input is two words separated with : with a postfix word should result in a single InChannel and a term",
1303			Input: "in:channel testing",
1304			Output: []*SearchParams{
1305				{
1306					Terms:              "testing",
1307					ExcludedTerms:      "",
1308					IsHashtag:          false,
1309					InChannels:         []string{"channel"},
1310					ExcludedChannels:   []string{},
1311					FromUsers:          []string{},
1312					ExcludedUsers:      []string{},
1313					Extensions:         []string{},
1314					ExcludedExtensions: []string{},
1315				},
1316			},
1317		},
1318		{
1319			Name:  "input is four words separated with : should result in a two InChannels",
1320			Input: "in:channel in:otherchannel",
1321			Output: []*SearchParams{
1322				{
1323					Terms:              "",
1324					ExcludedTerms:      "",
1325					IsHashtag:          false,
1326					InChannels:         []string{"channel", "otherchannel"},
1327					ExcludedChannels:   []string{},
1328					FromUsers:          []string{},
1329					ExcludedUsers:      []string{},
1330					Extensions:         []string{},
1331					ExcludedExtensions: []string{},
1332				},
1333			},
1334		},
1335		{
1336			Name:  "input is four words separated with : prefixed with a word should result in two InChannels and one term",
1337			Input: "testing in:channel in:otherchannel",
1338			Output: []*SearchParams{
1339				{
1340					Terms:              "testing",
1341					ExcludedTerms:      "",
1342					IsHashtag:          false,
1343					InChannels:         []string{"channel", "otherchannel"},
1344					ExcludedChannels:   []string{},
1345					FromUsers:          []string{},
1346					ExcludedUsers:      []string{},
1347					Extensions:         []string{},
1348					ExcludedExtensions: []string{},
1349				},
1350			},
1351		},
1352		{
1353			Name:  "input is four words separated with : prefixed with a word should result in one InChannel, one FromUser and one term",
1354			Input: "testing in:channel from:someone",
1355			Output: []*SearchParams{
1356				{
1357					Terms:              "testing",
1358					ExcludedTerms:      "",
1359					IsHashtag:          false,
1360					InChannels:         []string{"channel"},
1361					ExcludedChannels:   []string{},
1362					FromUsers:          []string{"someone"},
1363					ExcludedUsers:      []string{},
1364					Extensions:         []string{},
1365					ExcludedExtensions: []string{},
1366				},
1367			},
1368		},
1369		{
1370			Name:  "input is four words separated with : prefixed with a word should result in one InChannel, one ExcludedUser and one term",
1371			Input: "testing in:channel -from:someone",
1372			Output: []*SearchParams{
1373				{
1374					Terms:              "testing",
1375					ExcludedTerms:      "",
1376					IsHashtag:          false,
1377					InChannels:         []string{"channel"},
1378					ExcludedChannels:   []string{},
1379					FromUsers:          []string{},
1380					ExcludedUsers:      []string{"someone"},
1381					Extensions:         []string{},
1382					ExcludedExtensions: []string{},
1383				},
1384			},
1385		},
1386		{
1387			Name:  "input is six words separated with : prefixed with a word should result in one InChannel, one FromUser, one ExcludedUser and one term",
1388			Input: "testing in:channel from:someone -from:someoneelse",
1389			Output: []*SearchParams{
1390				{
1391					Terms:              "testing",
1392					ExcludedTerms:      "",
1393					IsHashtag:          false,
1394					InChannels:         []string{"channel"},
1395					ExcludedChannels:   []string{},
1396					FromUsers:          []string{"someone"},
1397					ExcludedUsers:      []string{"someoneelse"},
1398					Extensions:         []string{},
1399					ExcludedExtensions: []string{},
1400				},
1401			},
1402		},
1403		{
1404			Name:  "input is two words first one is prefixed with two #, should result in one term with IsHashtag = true, pluses should be removed",
1405			Input: "##hashtag +#plus+",
1406			Output: []*SearchParams{
1407				{
1408					Terms:              "#hashtag #plus",
1409					ExcludedTerms:      "",
1410					IsHashtag:          true,
1411					InChannels:         []string{},
1412					ExcludedChannels:   []string{},
1413					FromUsers:          []string{},
1414					ExcludedUsers:      []string{},
1415					Extensions:         []string{},
1416					ExcludedExtensions: []string{},
1417				},
1418			},
1419		},
1420		{
1421			Name:  "input is a wilrdcar with a *, should result in one term with a *",
1422			Input: "wildcar*",
1423			Output: []*SearchParams{
1424				{
1425					Terms:              "wildcar*",
1426					ExcludedTerms:      "",
1427					IsHashtag:          false,
1428					InChannels:         []string{},
1429					ExcludedChannels:   []string{},
1430					FromUsers:          []string{},
1431					ExcludedUsers:      []string{},
1432					Extensions:         []string{},
1433					ExcludedExtensions: []string{},
1434				},
1435			},
1436		},
1437		{
1438			Name:  "input is an after date with one word, should in one AfterDate and one term",
1439			Input: "after:2018-8-1 testing",
1440			Output: []*SearchParams{
1441				{
1442					Terms:              "testing",
1443					ExcludedTerms:      "",
1444					AfterDate:          "2018-8-1",
1445					ExcludedAfterDate:  "",
1446					InChannels:         []string{},
1447					ExcludedChannels:   []string{},
1448					FromUsers:          []string{},
1449					ExcludedUsers:      []string{},
1450					Extensions:         []string{},
1451					ExcludedExtensions: []string{},
1452				},
1453			},
1454		},
1455		{
1456			Name:  "input is an after date with one word, should in one ExcludedAfterDate and one term",
1457			Input: "-after:2018-8-1 testing",
1458			Output: []*SearchParams{
1459				{
1460					Terms:              "testing",
1461					ExcludedTerms:      "",
1462					AfterDate:          "",
1463					ExcludedAfterDate:  "2018-8-1",
1464					InChannels:         []string{},
1465					ExcludedChannels:   []string{},
1466					FromUsers:          []string{},
1467					ExcludedUsers:      []string{},
1468					Extensions:         []string{},
1469					ExcludedExtensions: []string{},
1470				},
1471			},
1472		},
1473		{
1474			Name:  "input is an on date with one word, should in one OnDate and one term",
1475			Input: "on:2018-8-1 testing",
1476			Output: []*SearchParams{
1477				{
1478					Terms:              "testing",
1479					ExcludedTerms:      "",
1480					OnDate:             "2018-8-1",
1481					AfterDate:          "",
1482					ExcludedAfterDate:  "",
1483					InChannels:         []string{},
1484					ExcludedChannels:   []string{},
1485					FromUsers:          []string{},
1486					ExcludedUsers:      []string{},
1487					Extensions:         []string{},
1488					ExcludedExtensions: []string{},
1489				},
1490			},
1491		},
1492		{
1493			Name:  "input is an on date with one word, should in one ExcludedDate and one term",
1494			Input: "-on:2018-8-1 testing",
1495			Output: []*SearchParams{
1496				{
1497					Terms:              "testing",
1498					ExcludedTerms:      "",
1499					AfterDate:          "",
1500					ExcludedDate:       "2018-8-1",
1501					InChannels:         []string{},
1502					ExcludedChannels:   []string{},
1503					FromUsers:          []string{},
1504					ExcludedUsers:      []string{},
1505					Extensions:         []string{},
1506					ExcludedExtensions: []string{},
1507				},
1508			},
1509		},
1510		{
1511			Name:  "input is an after date, should in one AfterDate",
1512			Input: "after:2018-8-1",
1513			Output: []*SearchParams{
1514				{
1515					Terms:              "",
1516					ExcludedTerms:      "",
1517					AfterDate:          "2018-8-1",
1518					ExcludedDate:       "",
1519					InChannels:         []string{},
1520					ExcludedChannels:   []string{},
1521					FromUsers:          []string{},
1522					ExcludedUsers:      []string{},
1523					Extensions:         []string{},
1524					ExcludedExtensions: []string{},
1525				},
1526			},
1527		},
1528		{
1529			Name:  "input is an before date, should in one BeforeDate",
1530			Input: "before:2018-8-1",
1531			Output: []*SearchParams{
1532				{
1533					Terms:              "",
1534					ExcludedTerms:      "",
1535					BeforeDate:         "2018-8-1",
1536					AfterDate:          "",
1537					ExcludedDate:       "",
1538					InChannels:         []string{},
1539					ExcludedChannels:   []string{},
1540					FromUsers:          []string{},
1541					ExcludedUsers:      []string{},
1542					Extensions:         []string{},
1543					ExcludedExtensions: []string{},
1544				},
1545			},
1546		},
1547		{
1548			Name:  "input is an before date, should in one ExcludedBeforeDate",
1549			Input: "-before:2018-8-1",
1550			Output: []*SearchParams{
1551				{
1552					Terms:              "",
1553					ExcludedTerms:      "",
1554					BeforeDate:         "",
1555					AfterDate:          "",
1556					ExcludedBeforeDate: "2018-8-1",
1557					InChannels:         []string{},
1558					ExcludedChannels:   []string{},
1559					FromUsers:          []string{},
1560					ExcludedUsers:      []string{},
1561					Extensions:         []string{},
1562					ExcludedExtensions: []string{},
1563				},
1564			},
1565		},
1566		{
1567			Name:  "input is two words separated with : and should result in a single Extension",
1568			Input: "ext:png",
1569			Output: []*SearchParams{
1570				{
1571					Terms:              "",
1572					ExcludedTerms:      "",
1573					IsHashtag:          false,
1574					InChannels:         []string{},
1575					ExcludedChannels:   []string{},
1576					FromUsers:          []string{},
1577					ExcludedUsers:      []string{},
1578					Extensions:         []string{"png"},
1579					ExcludedExtensions: []string{},
1580				},
1581			},
1582		},
1583		{
1584			Name:  "input is two words separated with :, prefied with - and should result in a single ExcludedExtensions",
1585			Input: "-ext:png",
1586			Output: []*SearchParams{
1587				{
1588					Terms:              "",
1589					ExcludedTerms:      "",
1590					IsHashtag:          false,
1591					InChannels:         []string{},
1592					ExcludedChannels:   []string{},
1593					FromUsers:          []string{},
1594					ExcludedUsers:      []string{},
1595					Extensions:         []string{},
1596					ExcludedExtensions: []string{"png"},
1597				},
1598			},
1599		},
1600		{
1601			Name:  "input is two words separated with : with a prefixed word should result in a single Extension and a term",
1602			Input: "testing ext:png",
1603			Output: []*SearchParams{
1604				{
1605					Terms:              "testing",
1606					ExcludedTerms:      "",
1607					IsHashtag:          false,
1608					InChannels:         []string{},
1609					ExcludedChannels:   []string{},
1610					FromUsers:          []string{},
1611					ExcludedUsers:      []string{},
1612					Extensions:         []string{"png"},
1613					ExcludedExtensions: []string{},
1614				},
1615			},
1616		},
1617		{
1618			Name:  "input is two words separated with : with a prefixed word should result in a single ExcludedExtension and a term",
1619			Input: "testing -ext:png",
1620			Output: []*SearchParams{
1621				{
1622					Terms:              "testing",
1623					ExcludedTerms:      "",
1624					IsHashtag:          false,
1625					InChannels:         []string{},
1626					ExcludedChannels:   []string{},
1627					FromUsers:          []string{},
1628					ExcludedUsers:      []string{},
1629					Extensions:         []string{},
1630					ExcludedExtensions: []string{"png"},
1631				},
1632			},
1633		},
1634		{
1635			Name:  "input is two words separated with : with a postfix word should result in a single Extension and a term",
1636			Input: "ext:png testing",
1637			Output: []*SearchParams{
1638				{
1639					Terms:              "testing",
1640					ExcludedTerms:      "",
1641					IsHashtag:          false,
1642					InChannels:         []string{},
1643					ExcludedChannels:   []string{},
1644					FromUsers:          []string{},
1645					ExcludedUsers:      []string{},
1646					Extensions:         []string{"png"},
1647					ExcludedExtensions: []string{},
1648				},
1649			},
1650		},
1651		{
1652			Name:  "input is four words separated with : should result in a two Extensions",
1653			Input: "ext:png ext:jpg",
1654			Output: []*SearchParams{
1655				{
1656					Terms:              "",
1657					ExcludedTerms:      "",
1658					IsHashtag:          false,
1659					InChannels:         []string{},
1660					ExcludedChannels:   []string{},
1661					FromUsers:          []string{},
1662					ExcludedUsers:      []string{},
1663					Extensions:         []string{"png", "jpg"},
1664					ExcludedExtensions: []string{},
1665				},
1666			},
1667		},
1668	} {
1669		t.Run(testCase.Name, func(t *testing.T) {
1670			require.Equal(t, testCase.Output, ParseSearchParams(testCase.Input, 0))
1671		})
1672	}
1673}
1674
1675func TestGetOnDateMillis(t *testing.T) {
1676	for _, testCase := range []struct {
1677		Name        string
1678		Input       string
1679		StartOnDate int64
1680		EndOnDate   int64
1681	}{
1682		{
1683			Name:        "Valid date",
1684			Input:       "2018-08-01",
1685			StartOnDate: 1533081600000,
1686			EndOnDate:   1533167999999,
1687		},
1688		{
1689			Name:        "Valid date but requires padding of zero",
1690			Input:       "2018-8-1",
1691			StartOnDate: 1533081600000,
1692			EndOnDate:   1533167999999,
1693		},
1694		{
1695			Name:        "Invalid date, date not exist",
1696			Input:       "2018-02-29",
1697			StartOnDate: 0,
1698			EndOnDate:   0,
1699		},
1700		{
1701			Name:        "Invalid date, not date format",
1702			Input:       "holiday",
1703			StartOnDate: 0,
1704			EndOnDate:   0,
1705		},
1706	} {
1707		t.Run(testCase.Name, func(t *testing.T) {
1708			sp := &SearchParams{OnDate: testCase.Input, TimeZoneOffset: 0}
1709			startOnDate, endOnDate := sp.GetOnDateMillis()
1710			assert.Equal(t, testCase.StartOnDate, startOnDate)
1711			assert.Equal(t, testCase.EndOnDate, endOnDate)
1712		})
1713	}
1714}
1715
1716func TestGetBeforeDateMillis(t *testing.T) {
1717	for _, testCase := range []struct {
1718		Name       string
1719		Input      string
1720		BeforeDate int64
1721	}{
1722		{
1723			Name:       "Valid date",
1724			Input:      "2018-08-01",
1725			BeforeDate: 1533081599999,
1726		},
1727		{
1728			Name:       "Valid date but requires padding of zero",
1729			Input:      "2018-8-1",
1730			BeforeDate: 1533081599999,
1731		},
1732		{
1733			Name:       "Invalid date, date not exist",
1734			Input:      "2018-02-29",
1735			BeforeDate: 0,
1736		},
1737		{
1738			Name:       "Invalid date, not date format",
1739			Input:      "holiday",
1740			BeforeDate: 0,
1741		},
1742	} {
1743		t.Run(testCase.Name, func(t *testing.T) {
1744			sp := &SearchParams{BeforeDate: testCase.Input, TimeZoneOffset: 0}
1745			beforeDate := sp.GetBeforeDateMillis()
1746			assert.Equal(t, testCase.BeforeDate, beforeDate)
1747		})
1748	}
1749}
1750
1751func TestGetAfterDateMillis(t *testing.T) {
1752	for _, testCase := range []struct {
1753		Name      string
1754		Input     string
1755		AfterDate int64
1756	}{
1757		{
1758			Name:      "Valid date",
1759			Input:     "2018-08-01",
1760			AfterDate: 1533168000000,
1761		},
1762		{
1763			Name:      "Valid date but requires padding of zero",
1764			Input:     "2018-8-1",
1765			AfterDate: 1533168000000,
1766		},
1767		{
1768			Name:      "Invalid date, date not exist",
1769			Input:     "2018-02-29",
1770			AfterDate: GetStartOfDayMillis(time.Now().Add(time.Hour*24), 0),
1771		},
1772		{
1773			Name:      "Invalid date, not date format",
1774			Input:     "holiday",
1775			AfterDate: GetStartOfDayMillis(time.Now().Add(time.Hour*24), 0),
1776		},
1777	} {
1778		t.Run(testCase.Name, func(t *testing.T) {
1779			sp := &SearchParams{AfterDate: testCase.Input, TimeZoneOffset: 0}
1780			afterDate := sp.GetAfterDateMillis()
1781			assert.Equal(t, testCase.AfterDate, afterDate)
1782		})
1783	}
1784}
1785
1786func TestIsSearchParamsListValid(t *testing.T) {
1787	var err *AppError
1788
1789	err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}, {IncludeDeletedChannels: true}})
1790	assert.Nil(t, err)
1791
1792	err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}, {IncludeDeletedChannels: false}})
1793	assert.NotNil(t, err)
1794
1795	err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}})
1796	assert.Nil(t, err)
1797
1798	err = IsSearchParamsListValid([]*SearchParams{})
1799	assert.Nil(t, err)
1800}
1801