Skip to content

Commit

Permalink
chore(localstorage): use cmp for test comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Dec 13, 2024
1 parent 98b18c7 commit fad0e77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/fatih/color v1.16.0
github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4
github.com/go-logfmt/logfmt v0.5.1
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/humanlogio/api/go v0.0.0-20241208082433-416862db1fa7
github.com/humanlogio/humanlog-pro v0.0.0-20241129104809-3580d74828a9
Expand Down
6 changes: 4 additions & 2 deletions pkg/localstorage/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
typesv1 "github.com/humanlogio/api/go/types/v1"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down Expand Up @@ -213,7 +214,8 @@ func RunTest(t *testing.T, constructor func(t *testing.T) Storage) {

require.Len(t, got, len(tt.want))
for i := range tt.want {
require.Equal(t, protojson.Format(tt.want[i]), protojson.Format(got[i]))
diff := cmp.Diff(tt.want[i], got[i], protocmp.Transform())
require.Empty(t, diff)
}
})
}
Expand Down

0 comments on commit fad0e77

Please sign in to comment.