1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/utils/once_writer_test.go

20 lines
368 B
Go
Raw Normal View History

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)
}
}