mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
663 B
35 lines
663 B
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package httplib
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
)
|
|
|
|
type MockResponseWriter struct {
|
|
header http.Header
|
|
|
|
StatusCode int
|
|
BodyBuffer bytes.Buffer
|
|
}
|
|
|
|
func (m *MockResponseWriter) Header() http.Header {
|
|
return m.header
|
|
}
|
|
|
|
func (m *MockResponseWriter) Write(bytes []byte) (int, error) {
|
|
if m.StatusCode == 0 {
|
|
m.StatusCode = http.StatusOK
|
|
}
|
|
return m.BodyBuffer.Write(bytes)
|
|
}
|
|
|
|
func (m *MockResponseWriter) WriteHeader(statusCode int) {
|
|
m.StatusCode = statusCode
|
|
}
|
|
|
|
func NewMockResponseWriter() *MockResponseWriter {
|
|
return &MockResponseWriter{header: http.Header{}}
|
|
}
|
|
|