mirror of
https://github.com/sstent/go-garth-cli.git
synced 2025-12-05 23:52:02 +00:00
15 lines
325 B
Go
15 lines
325 B
Go
package testutils
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
)
|
|
|
|
func MockJSONResponse(code int, body string) *httptest.Server {
|
|
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(code)
|
|
w.Write([]byte(body))
|
|
}))
|
|
}
|