mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-03-12 13:00:17 +00:00
Initial commit
This commit is contained in:
31
fileproc/writer_test.go
Normal file
31
fileproc/writer_test.go
Normal 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())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user