whatcanGOwrong

This commit is contained in:
2024-09-19 21:38:24 -04:00
commit d0ae4d841d
17908 changed files with 4096831 additions and 0 deletions
@@ -0,0 +1,2 @@
// Deprecated: Use [net/http/httptest] instead.
package http
@@ -0,0 +1,49 @@
package http
import (
"net/http"
)
// Deprecated: Use [net/http/httptest] instead.
type TestResponseWriter struct {
// StatusCode is the last int written by the call to WriteHeader(int)
StatusCode int
// Output is a string containing the written bytes using the Write([]byte) func.
Output string
// header is the internal storage of the http.Header object
header http.Header
}
// Deprecated: Use [net/http/httptest] instead.
func (rw *TestResponseWriter) Header() http.Header {
if rw.header == nil {
rw.header = make(http.Header)
}
return rw.header
}
// Deprecated: Use [net/http/httptest] instead.
func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
// assume 200 success if no header has been set
if rw.StatusCode == 0 {
rw.WriteHeader(200)
}
// add these bytes to the output string
rw.Output += string(bytes)
// return normal values
return 0, nil
}
// Deprecated: Use [net/http/httptest] instead.
func (rw *TestResponseWriter) WriteHeader(i int) {
rw.StatusCode = i
}
@@ -0,0 +1,18 @@
package http
import (
"net/http"
"github.com/stretchr/testify/mock"
)
// Deprecated: Use [net/http/httptest] instead.
type TestRoundTripper struct {
mock.Mock
}
// Deprecated: Use [net/http/httptest] instead.
func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
args := t.Called(req)
return args.Get(0).(*http.Response), args.Error(1)
}