fix(compose): fix a data race in a test BE-12231 (#1148)

pull/12455/merge
andres-portainer 2025-09-04 17:31:57 -03:00 committed by GitHub
parent f8ae5368bf
commit 54f6add45d
1 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"testing"
"github.com/compose-spec/compose-go/v2/consts"
@ -476,8 +477,20 @@ func Test_DeployWithRemoveOrphans(t *testing.T) {
}
}
type logger struct {
sync.Mutex
strings.Builder
}
func (l *logger) Write(p []byte) (n int, err error) {
l.Lock()
defer l.Unlock()
return l.Builder.Write(p)
}
func Test_DeployWithIgnoreOrphans(t *testing.T) {
var logOutput strings.Builder
var logOutput logger
oldLogger := zerolog.Logger
zerolog.Logger = zerolog.Output(&logOutput)
defer func() {