1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/gio/safe_test.go
Carlos Alexandro Becker 8cb4eb1654
fix: ruleguard and semgrep scans and fixes (#3364)
run semgrep-go ruleguard and semgrep scans

https://github.com/dgryski/semgrep-go

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2022-09-11 15:32:23 -03:00

32 lines
421 B
Go

package gio
import (
"bytes"
"io"
"sync"
"testing"
"github.com/stretchr/testify/require"
)
func TestSafe(t *testing.T) {
chars := 30
var b bytes.Buffer
w := Safe(&b)
var wg sync.WaitGroup
wg.Add(chars)
for i := 0; i < chars; i++ {
go func() {
s, err := io.WriteString(w, "a")
require.Equal(t, 1, s)
require.NoError(t, err)
wg.Done()
}()
}
wg.Wait()
require.Len(t, b.String(), chars)
}