(tb testing.TB, files httpServerFiles)
| 500 | } |
| 501 | |
| 502 | func newHTTPFileServer(tb testing.TB, files httpServerFiles) *httptest.Server { |
| 503 | tb.Helper() |
| 504 | var serverURL string |
| 505 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 506 | f, ok := files[r.URL.Path] |
| 507 | if !ok { |
| 508 | w.WriteHeader(http.StatusNotFound) |
| 509 | return |
| 510 | } |
| 511 | |
| 512 | w.Header().Set("Last-Modified", time.Now().Format("Mon, 02 Jan 2006 15:04:05 GMT")) |
| 513 | if f.lines != 0 { |
| 514 | writeTestLog(tb, w, int(f.lines)) |
| 515 | } else { |
| 516 | for _, name := range f.files { |
| 517 | fmt.Fprintln(w, serverURL+name) |
| 518 | } |
| 519 | } |
| 520 | })) |
| 521 | serverURL = ts.URL |
| 522 | return ts |
| 523 | } |
no test coverage detected