Removed the files to import again and made some adjusts.
Marcio de Souza Oliveira
3 years ago
0 | package filter | |
1 | ||
2 | import ( | |
3 | "testing" | |
4 | ) | |
5 | ||
6 | func TestNewFilterByName(t *testing.T) { | |
7 | scf, _ := NewFilterByName("status", "200") | |
8 | if _, ok := scf.(*StatusFilter); !ok { | |
9 | t.Errorf("Was expecting statusfilter") | |
10 | } | |
11 | ||
12 | szf, _ := NewFilterByName("size", "200") | |
13 | if _, ok := szf.(*SizeFilter); !ok { | |
14 | t.Errorf("Was expecting sizefilter") | |
15 | } | |
16 | ||
17 | wf, _ := NewFilterByName("word", "200") | |
18 | if _, ok := wf.(*WordFilter); !ok { | |
19 | t.Errorf("Was expecting wordfilter") | |
20 | } | |
21 | ||
22 | lf, _ := NewFilterByName("line", "200") | |
23 | if _, ok := lf.(*LineFilter); !ok { | |
24 | t.Errorf("Was expecting linefilter") | |
25 | } | |
26 | ||
27 | ref, _ := NewFilterByName("regexp", "200") | |
28 | if _, ok := ref.(*RegexpFilter); !ok { | |
29 | t.Errorf("Was expecting regexpfilter") | |
30 | } | |
31 | } | |
32 | ||
33 | func TestNewFilterByNameError(t *testing.T) { | |
34 | _, err := NewFilterByName("status", "invalid") | |
35 | if err == nil { | |
36 | t.Errorf("Was expecing an error") | |
37 | } | |
38 | } | |
39 | ||
40 | func TestNewFilterByNameNotFound(t *testing.T) { | |
41 | _, err := NewFilterByName("nonexistent", "invalid") | |
42 | if err == nil { | |
43 | t.Errorf("Was expecing an error with invalid filter name") | |
44 | } | |
45 | } |