WrittenHeaderInt->StatusCode

This commit is contained in:
Tyler Bunnell 2013-10-14 11:51:42 -06:00
parent 2b887b0d67
commit a4c09999de

View File

@ -8,8 +8,8 @@ import (
// allowing you to make assertions about how it was used. // allowing you to make assertions about how it was used.
type TestResponseWriter struct { type TestResponseWriter struct {
// WrittenHeaderInt is the last int written by the call to WriteHeader(int) // StatusCode is the last int written by the call to WriteHeader(int)
WrittenHeaderInt int StatusCode int
// Output is a string containing the written bytes using the Write([]byte) func. // Output is a string containing the written bytes using the Write([]byte) func.
Output string Output string
@ -32,7 +32,7 @@ func (rw *TestResponseWriter) Header() http.Header {
func (rw *TestResponseWriter) Write(bytes []byte) (int, error) { func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
// assume 200 success if no header has been set // assume 200 success if no header has been set
if rw.WrittenHeaderInt == 0 { if rw.StatusCode == 0 {
rw.WriteHeader(200) rw.WriteHeader(200)
} }
@ -44,7 +44,7 @@ func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
} }
// WriteHeader stores the HTTP status code in the WrittenHeaderInt. // WriteHeader stores the HTTP status code in the StatusCode.
func (rw *TestResponseWriter) WriteHeader(i int) { func (rw *TestResponseWriter) WriteHeader(i int) {
rw.WrittenHeaderInt = i rw.StatusCode = i
} }