File: unwrap_test.go

package info (click to toggle)
golang-github-felixge-httpsnoop 1.0.3-3~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 176 kB
  • sloc: makefile: 10
file content (27 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
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
package httpsnoop

import (
	"net/http/httptest"
	"testing"
)

func TestUnwrap(t *testing.T) {
	w := Wrap(httptest.NewRecorder(), Hooks{})
	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
		t.Error("expected ResponseRecorder")
	}
}

func TestUnwrapWithoutWrap(t *testing.T) {
	w := httptest.NewRecorder()
	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
		t.Error("expected ResponseRecorder")
	}
}

func TestUnwrapMultipleLayers(t *testing.T) {
	w := Wrap(Wrap(httptest.NewRecorder(), Hooks{}), Hooks{})
	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
		t.Error("expected ResponseRecorder")
	}
}