23 lines
600 B
Go
23 lines
600 B
Go
package handlers
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
type offlineDefaultTransport struct{}
|
|
|
|
func (offlineDefaultTransport) RoundTrip(*http.Request) (*http.Response, error) {
|
|
return nil, errors.New("offline handler tests prohibit default network access")
|
|
}
|
|
|
|
func TestMain(m *testing.M) {
|
|
// Fixtures supply in-memory transports or httptest server-specific clients.
|
|
// In particular, error-notification code cannot reach a live email service.
|
|
http.DefaultTransport = offlineDefaultTransport{}
|
|
http.DefaultClient = &http.Client{Transport: http.DefaultTransport}
|
|
os.Exit(m.Run())
|
|
}
|