Skip to content

Commit 33bef19

Browse files
authored
test: add primitives tests (#3987)
test coverage Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
1 parent 8ac9a7f commit 33bef19

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package primitive
2+
3+
import (
4+
"net/http"
5+
"testing"
6+
)
7+
8+
func TestFalse(t *testing.T) {
9+
f := NewFalse()
10+
req, _ := http.NewRequest("GET", "http://false.test", nil)
11+
p, err := f.Create(nil)
12+
if err != nil {
13+
t.Fatalf("Failed to create: %v", err)
14+
}
15+
if p.Match(req) {
16+
t.Fatal("False() should never match")
17+
}
18+
if f.Name() == "" {
19+
t.Fatal("predicate should have a name")
20+
}
21+
}
22+
23+
func TestTrue(t *testing.T) {
24+
tr := NewTrue()
25+
req, _ := http.NewRequest("GET", "http://true.test", nil)
26+
p, err := tr.Create(nil)
27+
if err != nil {
28+
t.Fatalf("Failed to create: %v", err)
29+
}
30+
if !p.Match(req) {
31+
t.Fatal("True() should always match")
32+
}
33+
if tr.Name() == "" {
34+
t.Fatal("predicate should have a name")
35+
}
36+
}

0 commit comments

Comments
 (0)