runTests keeps tests away from the network and the real cache folder. Tests that need schemas call useTestSchemas.
(m *testing.M)
| 40 | // runTests keeps tests away from the network and the real cache folder. Tests |
| 41 | // that need schemas call useTestSchemas. |
| 42 | func runTests(m *testing.M) int { |
| 43 | cache, err := os.MkdirTemp("", "ghmock-test-cache-") |
| 44 | if err != nil { |
| 45 | fmt.Fprintln(os.Stderr, err) |
| 46 | return 1 |
| 47 | } |
| 48 | defer os.RemoveAll(cache) |
| 49 | userCacheDir = func() (string, error) { return cache, nil } |
| 50 | downloadClient = &http.Client{Transport: failingTransport{}} |
| 51 | os.Unsetenv(graphQLSource.envVar) |
| 52 | os.Unsetenv(restSource.envVar) |
| 53 | return m.Run() |
| 54 | } |
| 55 | |
| 56 | type failingTransport struct{} |
| 57 |