mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-14 11:23:09 +02:00
20 lines
368 B
Go
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)
|
||
|
}
|
||
|
}
|