mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-11 03:57:01 +00:00
Bump all dependencies (#4266)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -419,9 +420,14 @@ func TestGetValidCapacityReservations(t *testing.T) {
|
||||
func installTestLogger(webhook *HorizontalRunnerAutoscalerGitHubWebhook) *bytes.Buffer {
|
||||
logs := &bytes.Buffer{}
|
||||
|
||||
// Wrap the buffer with a synchronized writer to prevent race conditions
|
||||
syncWriter := &syncWriter{
|
||||
writer: logs,
|
||||
}
|
||||
|
||||
sink := &testLogSink{
|
||||
name: "testlog",
|
||||
writer: logs,
|
||||
writer: syncWriter,
|
||||
}
|
||||
|
||||
log := logr.New(sink)
|
||||
@@ -517,6 +523,18 @@ func sendWebhook(server *httptest.Server, eventType string, event interface{}) (
|
||||
return http.DefaultClient.Do(req)
|
||||
}
|
||||
|
||||
// syncWriter wraps an io.Writer with a mutex for thread-safe writes
|
||||
type syncWriter struct {
|
||||
writer io.Writer
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (sw *syncWriter) Write(p []byte) (n int, err error) {
|
||||
sw.mu.Lock()
|
||||
defer sw.mu.Unlock()
|
||||
return sw.writer.Write(p)
|
||||
}
|
||||
|
||||
// testLogSink is a sample logr.Logger that logs in-memory.
|
||||
// It's only for testing log outputs.
|
||||
type testLogSink struct {
|
||||
|
||||
Reference in New Issue
Block a user