func TestCheckReset(t *testing.T) {
	ck := NewPeek(nil, nil)
	writeHeader(ck, nil)
	writeCode(ck, nil)
	ck.Reset()
	if ck.HasChanged() {
		t.Errorf("should not have changed, but has")
	}
	if ck.Header().Get("a") != "" {
		t.Errorf(`header a should be "", but is: %#v`, ck.Header().Get("a"))
	}
}
/*
func TestCheckFlushHeaders2(t *testing.T) {
ckB := NewPeek(nil, nil)
ckA := NewPeek(ckB, nil)

writeHeader(ckA, nil)
ckA.FlushCode()

defer func() {
if recover() == nil {
t.Errorf("should panic if code is written before headers, but does not")
}
}()

ckA.FlushHeaders()

}
package wrap
import (
	"bufio"
	"net"
	"net/http"
	"net/http/httptest"
	"testing"
	"github.com/go-on/wrap-contrib/helper"
)
func writeHeader(rw http.ResponseWriter, req *http.Request) {
	rw.Header().Set("a", "b")
}
func writeCode(rw http.ResponseWriter, req *http.Request) {
	rw.WriteHeader(407)
}
func writeCodeCreated(rw http.ResponseWriter, req *http.Request) {
	rw.WriteHeader(201)
}
func TestPeek(t *testing.T) {
	ck := NewPeek(nil, nil)
	writeHeader(ck, nil)
	if !ck.HasChanged() {
		t.Errorf("should have changed, but has not")
	}
	if ck.Header().Get("a") != "b" {
		t.Errorf("header a should be b, but is: %#v", ck.Header().Get("a"))
	}
}
func TestPeekFlushMissing1(t *testing.T) {
	ckB := NewPeek(nil, nil)
	ck := NewPeek(ckB, nil)
	writeHeader(ck, nil)
	writeCode(ck, nil)
	ck.FlushMissing()
	if !ckB.HasChanged() {
		t.Errorf("should have changed, but has not")
	}
	if ckB.Header().Get("a") != "b" {
		t.Errorf("header a should be b, but is: %#v", ckB.Header().Get("a"))
	}
	if ckB.Code != 407 {
		t.Errorf("code should be 407, but is: %d", ckB.Code)
	}
}
func TestPeekFlushMissing2(t *testing.T) {
	ckB := NewPeek(nil, nil)
	ck := NewPeek(ckB, nil)
	writeCode(ck, nil)
	ck.FlushCode()
	if ckB.Code != 407 {
		t.Errorf("code should be 407, but is: %d", ckB.Code)
	}
	ckB.changed = false
	ck.FlushMissing()
	if ckB.HasChanged() {
		t.Errorf("should not have changed, but has")
	}
	if ckB.Code != 407 {
		t.Errorf("code should be 407, but is: %d", ckB.Code)
	}
}
func TestCheckResponseCode(t *testing.T) {
	ck := NewPeek(nil, nil)
	writeCode(ck, nil)
	if !ck.HasChanged() {
		t.Errorf("should have changed, but has not")
	}
	if ck.Code != 407 {
		t.Errorf("code should be 407, but is: %v", ck.Code)
	}
}
func TestCheckResponseIsOk1(t *testing.T) {
	ck := NewPeek(nil, nil)
	NoOp(ck, nil)
	if !ck.IsOk() {
		t.Errorf("should be ok when doing nothing, but is not")
	}
}
func TestCheckResponseIsOk2(t *testing.T) {
	ck := NewPeek(nil, nil)
	writeCodeCreated(ck, nil)
	if !ck.IsOk() {
		t.Errorf("should be ok with code 201, but is not")
	}
}
func TestCheckResponseIsOk3(t *testing.T) {
	ck := NewPeek(nil, nil)
	writeCode(ck, nil)
	if ck.IsOk() {
		t.Errorf("should not be ok with code 407, but is")
	}
}
func TestFlushCode(t *testing.T) {
	ckB := NewPeek(nil, nil)
	ckA := NewPeek(ckB, nil)
	writeCode(ckA, nil)
	ckA.FlushCode()
	if !ckB.HasChanged() {
		t.Errorf("should have changed, but has not")
	}
	if ckB.Code != 407 {
		t.Errorf("code should be 407, but is: %v", ckB.Code)
	}
	ckB.Code = 0
	ckA.FlushCode()
	if ckB.Code != 0 {
		t.Errorf("code should be 0, but is: %v", ckB.Code)
	}
}
func TestCheckFlushHeaders1(t *testing.T) {
	ckB := NewPeek(nil, nil)
	ckA := NewPeek(ckB, nil)
	writeHeader(ckA, nil)
	ckA.FlushHeaders()
	if !ckB.HasChanged() {
		t.Errorf("should have changed, but has not")
	}
	if ckB.Header().Get("a") != "b" {
		t.Errorf("header a should be b, but is: %#v", ckB.Header().Get("a"))
	}
	ckB.Header().Set("a", "")
	ckA.FlushHeaders()
	if ckB.Header().Get("a") != "" {
		t.Errorf(`header a should be "", but is: %#v`, ckB.Header().Get("a"))
	}
}