Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Nov 29, 2024
1 parent 0f2bea8 commit 124c55c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions internal/http/manage_runner_health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestSendRunnerHealthCheckRequest(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
if tt.serverDelay > 0 {
time.Sleep(tt.serverDelay)
}
Expand Down Expand Up @@ -74,15 +74,15 @@ func TestMonitorRunnerHealth(t *testing.T) {
}{
{
name: "healthy runner",
serverFn: func(w http.ResponseWriter, r *http.Request) {
serverFn: func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
},
expectedStatus: StatusMonitoringCancelled,
timeout: 200 * time.Millisecond,
},
{
name: "unhealthy runner",
serverFn: func(w http.ResponseWriter, r *http.Request) {
serverFn: func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
},
expectedStatus: StatusUnhealthy,
Expand All @@ -92,7 +92,7 @@ func TestMonitorRunnerHealth(t *testing.T) {
name: "alternating health status",
serverFn: func() http.HandlerFunc {
isHealthy := true
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
if isHealthy {
w.WriteHeader(http.StatusOK)
} else {
Expand Down Expand Up @@ -135,14 +135,14 @@ func TestManageRunnerHealth(t *testing.T) {
}{
{
name: "healthy runner not killed",
serverFn: func(w http.ResponseWriter, r *http.Request) {
serverFn: func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
},
expectKill: false,
},
{
name: "unhealthy runner killed",
serverFn: func(w http.ResponseWriter, r *http.Request) {
serverFn: func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
},
expectKill: true,
Expand Down Expand Up @@ -187,7 +187,10 @@ func TestManageRunnerHealth(t *testing.T) {
err := cmd.Process.Signal(syscall.Signal(0))
if err == nil {
t.Error("Expected process to be killed but it was still running")
cmd.Process.Kill() // to clean up
err := cmd.Process.Kill() // to clean up
if err != nil {
t.Errorf("Failed to kill process: %v", err)
}
}
}
}
Expand All @@ -198,7 +201,7 @@ func TestManageRunnerHealth(t *testing.T) {
}

func TestContextCancellation(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer srv.Close()
Expand Down

0 comments on commit 124c55c

Please sign in to comment.