| OLD | NEW |
| 1 package main | 1 package main |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "database/sql" | 4 "database/sql" |
| 5 "fmt" | 5 "fmt" |
| 6 "io/ioutil" | 6 "io/ioutil" |
| 7 "net/http" | 7 "net/http" |
| 8 "os" | 8 "os" |
| 9 "path/filepath" | 9 "path/filepath" |
| 10 "regexp" | 10 "regexp" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // Test that updateWebappTaskSetFailed returns an error when the server response
indicates an error. | 364 // Test that updateWebappTaskSetFailed returns an error when the server response
indicates an error. |
| 365 func TestUpdateWebappTaskSetFailedFailure(t *testing.T) { | 365 func TestUpdateWebappTaskSetFailedFailure(t *testing.T) { |
| 366 errstr := "You must be at least this tall to ride this ride." | 366 errstr := "You must be at least this tall to ride this ride." |
| 367 task := pendingRecreateWebpageArchivesTask() | 367 task := pendingRecreateWebpageArchivesTask() |
| 368 reqCount := 0 | 368 reqCount := 0 |
| 369 mockServer := func(w http.ResponseWriter, r *http.Request) { | 369 mockServer := func(w http.ResponseWriter, r *http.Request) { |
| 370 reqCount++ | 370 reqCount++ |
| 371 assert.Equal(t, "/"+ctfeutil.UPDATE_RECREATE_WEBPAGE_ARCHIVES_TA
SK_POST_URI, | 371 assert.Equal(t, "/"+ctfeutil.UPDATE_RECREATE_WEBPAGE_ARCHIVES_TA
SK_POST_URI, |
| 372 r.URL.Path) | 372 r.URL.Path) |
| 373 defer skutil.Close(r.Body) | 373 defer skutil.Close(r.Body) |
| 374 » » skutil.ReportError(w, r, fmt.Errorf(errstr), "") | 374 » » skutil.ReportError(w, r, fmt.Errorf(errstr), errstr) |
| 375 } | 375 } |
| 376 defer frontend.CloseTestServer(frontend.InitTestServer(http.HandlerFunc(
mockServer))) | 376 defer frontend.CloseTestServer(frontend.InitTestServer(http.HandlerFunc(
mockServer))) |
| 377 err := updateWebappTaskSetFailed(&task) | 377 err := updateWebappTaskSetFailed(&task) |
| 378 assert.Error(t, err) | 378 assert.Error(t, err) |
| 379 assert.Contains(t, err.Error(), errstr) | 379 assert.Contains(t, err.Error(), errstr) |
| 380 assert.Equal(t, 1, reqCount) | 380 assert.Equal(t, 1, reqCount) |
| 381 } | 381 } |
| 382 | 382 |
| 383 func TestDoWorkerHealthCheck(t *testing.T) { | 383 func TestDoWorkerHealthCheck(t *testing.T) { |
| 384 mockExec := exec.CommandCollector{} | 384 mockExec := exec.CommandCollector{} |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 pollAndExecOnce() | 511 pollAndExecOnce() |
| 512 pollAndExecOnce() | 512 pollAndExecOnce() |
| 513 pollAndExecOnce() | 513 pollAndExecOnce() |
| 514 // Expect three polls. | 514 // Expect three polls. |
| 515 expect.Equal(t, 3, mockServer.OldestPendingTaskReqCount()) | 515 expect.Equal(t, 3, mockServer.OldestPendingTaskReqCount()) |
| 516 // Expect no commands. | 516 // Expect no commands. |
| 517 expect.Empty(t, mockExec.Commands()) | 517 expect.Empty(t, mockExec.Commands()) |
| 518 // No updates expected. | 518 // No updates expected. |
| 519 expect.Empty(t, mockServer.UpdateTaskReqs()) | 519 expect.Empty(t, mockServer.UpdateTaskReqs()) |
| 520 } | 520 } |
| OLD | NEW |