featurebase/test/transaction.go
reesporte 48aef0c8a4 add copyright notice back in
```bash
for file in `cat diffys`; do
   printf '%s\n%s\n' "// Copyright 2021 Molecula Corp. All rights reserved." "$(cat $file)" >$file;
done
```
2021-12-10 11:01:04 -06:00

33 lines
798 B
Go

// Copyright 2021 Molecula Corp. All rights reserved.
package test
import (
"testing"
"time"
"github.com/molecula/featurebase/v2"
)
const deadlineSkew = time.Second
// CompareTransactions errors describing how the
// transactions differ (if at all). The deadlines need only be close
// (within deadlineSkew).
func CompareTransactions(t *testing.T, trns1, trns2 *pilosa.Transaction) {
t.Helper()
if err := pilosa.CompareTransactions(trns1, trns2); err != nil {
t.Errorf("%v", err)
}
if trns1 == nil || trns2 == nil {
return
}
diff := trns1.Deadline.Sub(trns2.Deadline)
if diff > deadlineSkew || diff < -deadlineSkew {
t.Errorf("Deadlines differ by %v:\n%+v\n%+v", diff, trns1, trns2)
}
if trns1.Stats != trns2.Stats {
t.Errorf("Stats differ:\n%+v\n%+v", trns1, trns2)
}
}