Initial commit

This commit is contained in:
Ismo Vuorinen
2025-02-07 09:15:37 +02:00
commit b9e2218305
19 changed files with 873 additions and 0 deletions

31
fileproc/writer_test.go Normal file
View File

@@ -0,0 +1,31 @@
package fileproc
import (
"bytes"
"sync"
"testing"
)
func TestStartWriter(t *testing.T) {
var buf bytes.Buffer
writeCh := make(chan WriteRequest)
done := make(chan struct{})
go StartWriter(&buf, writeCh, done)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
writeCh <- WriteRequest{Content: "Hello"}
writeCh <- WriteRequest{Content: " World"}
}()
wg.Wait()
close(writeCh)
<-done
if buf.String() != "Hello World" {
t.Errorf("Expected 'Hello World', got '%s'", buf.String())
}
}