mirror of
https://github.com/restic/restic.git
synced 2026-06-27 11:04:17 +00:00
data/fs: faster comparison in tests
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -275,11 +276,12 @@ func TestApplyPolicy(t *testing.T) {
|
||||
|
||||
cmpOpts := cmpopts.IgnoreUnexported(data.Snapshot{})
|
||||
|
||||
if !cmp.Equal(want.Keep, keep, cmpOpts) {
|
||||
// reflect.DeepEqual is faster than cmp.Equal
|
||||
if !reflect.DeepEqual(want.Keep, keep) {
|
||||
t.Error(cmp.Diff(want.Keep, keep, cmpOpts))
|
||||
}
|
||||
|
||||
if !cmp.Equal(want.Reasons, reasons, cmpOpts) {
|
||||
if !reflect.DeepEqual(want.Reasons, reasons) {
|
||||
t.Error(cmp.Diff(want.Reasons, reasons, cmpOpts))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -23,7 +24,8 @@ func verifyFileContentOpenFile(t testing.TB, fs FS, filename string, want []byte
|
||||
test.OK(t, err)
|
||||
test.OK(t, f.Close())
|
||||
|
||||
if !cmp.Equal(want, buf) {
|
||||
// slices.Equal is much faster than cmp.Equal
|
||||
if !slices.Equal(want, buf) {
|
||||
t.Error(cmp.Diff(want, buf))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user