papero/fs/oracle_test.go

36 lines
951 B
Go
Raw Normal View History

2021-01-17 20:07:40 +01:00
package fs
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestOracle(t *testing.T) {
var message_nums = []int{0, 1, 2, 3, 4}
var results []MailFile
clock := mockClock{}
oracle := newOracle(clock)
for range message_nums {
req := NewMailFileRequest()
oracle <- req
results = append(results, req.Response())
}
for i := range message_nums[1:] {
timestamp_c := results[0].timestamp != results[i].timestamp
pid_c := results[0].pid != results[i].pid
hostname_c := results[0].hostname != results[i].hostname
if timestamp_c || pid_c || hostname_c {
t.Logf("timestamp_c: %+v\n", timestamp_c)
t.Logf("pid_c: %+v\n", pid_c)
t.Logf("hostname_c: %+v\n", hostname_c)
t.Errorf("Mismatching timestamps, %+v\n", cmp.Diff(results[0], results[i], cmp.AllowUnexported(MailFile{})))
}
if results[i].progressive != i {
t.Errorf("Unexpected progressive -> have: %d | expect: %d\n", results[i].progressive, i)
}
}
}