gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/httpsnoop/unwrap_test.go (about)

     1  package httpsnoop
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gitee.com/ks-custle/core-gm/gmhttp/httptest"
     7  )
     8  
     9  func TestUnwrap(t *testing.T) {
    10  	w := Wrap(httptest.NewRecorder(), Hooks{})
    11  	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
    12  		t.Error("expected ResponseRecorder")
    13  	}
    14  }
    15  
    16  func TestUnwrapWithoutWrap(t *testing.T) {
    17  	w := httptest.NewRecorder()
    18  	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
    19  		t.Error("expected ResponseRecorder")
    20  	}
    21  }
    22  
    23  func TestUnwrapMultipleLayers(t *testing.T) {
    24  	w := Wrap(Wrap(httptest.NewRecorder(), Hooks{}), Hooks{})
    25  	if _, ok := Unwrap(w).(*httptest.ResponseRecorder); !ok {
    26  		t.Error("expected ResponseRecorder")
    27  	}
    28  }