writeCache writes a fresh on-disk catalog cache the Store can load without touching the network.
(tb testing.TB, path string, db Database)
| 17 | // writeCache writes a fresh on-disk catalog cache the Store can load without |
| 18 | // touching the network. |
| 19 | func writeCache(tb testing.TB, path string, db Database) { |
| 20 | tb.Helper() |
| 21 | data, err := json.Marshal(CachedData{Database: db, LastRefresh: time.Now()}) |
| 22 | require.NoError(tb, err) |
| 23 | require.NoError(tb, os.WriteFile(path, data, 0o600)) |
| 24 | } |
| 25 | |
| 26 | // expiredContext returns a context whose deadline is already in the past, so |
| 27 | // any HTTP request built from it fails instantly without touching the network. |
no test coverage detected