MCPcopy Create free account
hub / github.com/exercism/cli / fakeDownloadServer

Function fakeDownloadServer

cmd/download_test.go:300–326  ·  view source on GitHub ↗
(requestor string)

Source from the content-addressed store, hash-verified

298}
299
300func fakeDownloadServer(requestor string) *httptest.Server {
301 mux := http.NewServeMux()
302 server := httptest.NewServer(mux)
303
304 mux.HandleFunc("/file-1.txt", func(w http.ResponseWriter, r *http.Request) {
305 fmt.Fprint(w, "this is file 1")
306 })
307
308 mux.HandleFunc("/subdir/file-2.txt", func(w http.ResponseWriter, r *http.Request) {
309 fmt.Fprint(w, "this is file 2")
310 })
311
312 mux.HandleFunc("/file-3.txt", func(w http.ResponseWriter, r *http.Request) {
313 fmt.Fprint(w, "")
314 })
315
316 mux.HandleFunc("/solutions/latest", func(w http.ResponseWriter, r *http.Request) {
317 payloadBody := fmt.Sprintf(payloadTemplate, requestor, server.URL+"/")
318 fmt.Fprint(w, payloadBody)
319 })
320 mux.HandleFunc("/solutions/bogus-id", func(w http.ResponseWriter, r *http.Request) {
321 payloadBody := fmt.Sprintf(payloadTemplate, requestor, server.URL+"/")
322 fmt.Fprint(w, payloadBody)
323 })
324
325 return server
326}
327
328func assertDownloadedCorrectFiles(t *testing.T, targetDir string) {
329 expectedFiles := []struct {

Callers 3

TestDownloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected