forked from extrame/goblet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatcher_test.go
39 lines (33 loc) · 839 Bytes
/
matcher_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package goblet
import (
"fmt"
"testing"
)
type TestController struct {
Route `/api/test`
SingleController
}
type TestController2 struct {
Route `/api`
GroupController
}
func TestMatchSimpleController(t *testing.T) {
matched, suffix := TestMatcher("/api/test/123/456", &TestController2{}, &TestController{})
if suffix != "/123/456" {
t.Error("suffix should be /123/456, but got", suffix)
}
if matched != "Html(TestController)" {
t.Error("matched should be Html(TestController), but got", matched)
}
}
func TestAttrMap(t *testing.T) {
var lctx = &LoginContext{}
WithAttribute("test", []string{"test1"})(lctx)
if !lctx.HasAttr("test", "test1") {
t.Error("should has attr test1")
}
}
func TestCompareFloatAndInt(t *testing.T) {
var result = compareStringAndNumber(float64(1), 1)
fmt.Println("result is", result)
}