(t *testing.T)
| 244 | } |
| 245 | |
| 246 | func TestIdleConnection(t *testing.T) { |
| 247 | s := &Server{ |
| 248 | s: &fasthttp.Server{ |
| 249 | Handler: func(ctx *fasthttp.RequestCtx) { |
| 250 | io.WriteString(ctx, "Hello world") |
| 251 | }, |
| 252 | ReadTimeout: time.Second * 5, |
| 253 | IdleTimeout: time.Second * 2, |
| 254 | }, |
| 255 | cnf: ServerConfig{ |
| 256 | Debug: false, |
| 257 | }, |
| 258 | } |
| 259 | |
| 260 | c, ln, err := getConn(s) |
| 261 | if err != nil { |
| 262 | t.Fatal(err) |
| 263 | } |
| 264 | defer c.Close() |
| 265 | defer ln.Close() |
| 266 | |
| 267 | h1 := makeHeaders(3, c.enc, true, true, map[string]string{ |
| 268 | string(StringAuthority): "localhost", |
| 269 | string(StringMethod): "GET", |
| 270 | string(StringPath): "/hello/world", |
| 271 | string(StringScheme): "https", |
| 272 | }) |
| 273 | |
| 274 | c.writeFrame(h1) |
| 275 | |
| 276 | expect := []FrameType{ |
| 277 | FrameHeaders, FrameData, |
| 278 | } |
| 279 | |
| 280 | for i := 0; i < 2; i++ { |
| 281 | fr, err := c.readNext() |
| 282 | if err != nil { |
| 283 | t.Fatal(err) |
| 284 | } |
| 285 | |
| 286 | if fr.Stream() != 3 { |
| 287 | t.Fatalf("Expecting update on stream %d, got %d", 3, fr.Stream()) |
| 288 | } |
| 289 | |
| 290 | if fr.Type() != expect[i] { |
| 291 | t.Fatalf("Expecting %s, got %s", expect[i], fr.Type()) |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | _, err = c.readNext() |
| 296 | if err != nil { |
| 297 | if _, ok := err.(*GoAway); !ok { |
| 298 | t.Fatal(err) |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | _, err = c.readNext() |
| 303 | if err == nil { |
nothing calls this directly
no test coverage detected