(requestor string)
| 298 | } |
| 299 | |
| 300 | func 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 | |
| 328 | func assertDownloadedCorrectFiles(t *testing.T, targetDir string) { |
| 329 | expectedFiles := []struct { |
no outgoing calls
no test coverage detected