1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-02 09:21:40 +02:00
lazygit/pkg/utils/once_writer_test.go
Jesse Duffield 755ae0ef84 add deadlock mutex package
write to deadlock stderr after closing gocui

more deadlock checking
2022-08-07 11:16:14 +10:00

20 lines
368 B
Go

package utils
import (
"bytes"
"testing"
)
func TestOnceWriter(t *testing.T) {
innerWriter := bytes.NewBuffer(nil)
counter := 0
onceWriter := NewOnceWriter(innerWriter, func() {
counter += 1
})
_, _ = onceWriter.Write([]byte("hello"))
_, _ = onceWriter.Write([]byte("hello"))
if counter != 1 {
t.Errorf("expected counter to be 1, got %d", counter)
}
}