Commit aedc1339 authored by ale's avatar ale

Use go-cmp instead of reflect.DeepEqual

parent 589dd889
package auth
import (
"encoding/json"
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/tstranex/u2f"
)
......@@ -40,10 +39,8 @@ func TestProtocol_SerializeRequest(t *testing.T) {
if err != nil {
t.Fatal("Decode():", err)
}
if !reflect.DeepEqual(req, &req2) {
d1, _ := json.MarshalIndent(req, "", " ")
d2, _ := json.MarshalIndent(req2, "", " ")
t.Errorf("decode results differ: %+v vs %+v", string(d1), string(d2))
if diffs := cmp.Diff(req, &req2); diffs != "" {
t.Errorf("decode results differ:\n%s", diffs)
}
}
......@@ -83,9 +80,7 @@ func TestProtocol_SerializeResponse(t *testing.T) {
if err != nil {
t.Fatal("Decode():", err)
}
if !reflect.DeepEqual(resp, &resp2) {
d1, _ := json.MarshalIndent(resp, "", " ")
d2, _ := json.MarshalIndent(resp2, "", " ")
t.Errorf("decode results differ: %+v vs %+v", string(d1), string(d2))
if diffs := cmp.Diff(resp, &resp2); diffs != "" {
t.Errorf("decode results differ: %s", diffs)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment