2022-05-31 21:53:01 +02:00
|
|
|
package tracex
|
2021-02-02 12:05:47 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGood(t *testing.T) {
|
2022-05-31 21:53:01 +02:00
|
|
|
saver := Saver{}
|
2021-02-02 12:05:47 +01:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
const parallel = 10
|
|
|
|
wg.Add(parallel)
|
|
|
|
for idx := 0; idx < parallel; idx++ {
|
|
|
|
go func() {
|
2022-05-31 21:53:01 +02:00
|
|
|
saver.Write(Event{})
|
2021-02-02 12:05:47 +01:00
|
|
|
wg.Done()
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != parallel {
|
|
|
|
t.Fatal("unexpected number of events read")
|
|
|
|
}
|
|
|
|
}
|