c740be987b
Rather than matching a string, match a type. This is more robust considering future refactorings. We're confident the names did not change in _this_ refactoring because we're still testing the same strings in the tests. Part of https://github.com/ooni/probe/issues/2121
25 lines
396 B
Go
25 lines
396 B
Go
package tracex
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
func TestSaver(t *testing.T) {
|
|
saver := Saver{}
|
|
var wg sync.WaitGroup
|
|
const parallel = 10
|
|
wg.Add(parallel)
|
|
for idx := 0; idx < parallel; idx++ {
|
|
go func() {
|
|
saver.Write(&EventReadFromOperation{&EventValue{}})
|
|
wg.Done()
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
ev := saver.Read()
|
|
if len(ev) != parallel {
|
|
t.Fatal("unexpected number of events read")
|
|
}
|
|
}
|