MCPcopy Create free account
hub / github.com/AdRoll/baker / newHTTPFileServer

Function newHTTPFileServer

input/list_test.go:502–523  ·  view source on GitHub ↗
(tb testing.TB, files httpServerFiles)

Source from the content-addressed store, hash-verified

500}
501
502func 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}

Callers 1

TestListHttpFileFunction · 0.85

Calls 2

writeTestLogFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected