(t *testing.T)
| 114 | } |
| 115 | |
| 116 | func TestBindMiddleware(t *testing.T) { |
| 117 | var value *bindTestStruct |
| 118 | var called bool |
| 119 | router := New() |
| 120 | router.GET("/", Bind(bindTestStruct{}), func(c *Context) { |
| 121 | called = true |
| 122 | value = c.MustGet(BindKey).(*bindTestStruct) |
| 123 | }) |
| 124 | PerformRequest(router, http.MethodGet, "/?foo=hola&bar=10") |
| 125 | assert.True(t, called) |
| 126 | assert.Equal(t, "hola", value.Foo) |
| 127 | assert.Equal(t, 10, value.Bar) |
| 128 | |
| 129 | called = false |
| 130 | PerformRequest(router, http.MethodGet, "/?foo=hola&bar=1") |
| 131 | assert.False(t, called) |
| 132 | |
| 133 | assert.Panics(t, func() { |
| 134 | Bind(&bindTestStruct{}) |
| 135 | }) |
| 136 | } |
| 137 | |
| 138 | func TestMarshalXMLforH(t *testing.T) { |
| 139 | h := H{ |
nothing calls this directly
no test coverage detected