encoding/textpb: fix failed tests due to ordering of marshaled binary fields

Added temporary work-around for now by always using deterninistic
marshaling so that protoV1.Equals knows how to do comparison.

Change-Id: Idec412647269d59f86ed3e485a1893c070355b3d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167917
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Herbie Ong 2019-03-15 19:32:38 -07:00
parent 4d1c3be76f
commit e0cf15babe
2 changed files with 2 additions and 2 deletions

View File

@ -486,7 +486,7 @@ func (o UnmarshalOptions) unmarshalAny(tfield [2]text.Value, knownFields pref.Kn
return err return err
} }
// Serialize the embedded message and assign the resulting bytes to the value field. // Serialize the embedded message and assign the resulting bytes to the value field.
b, err := proto.Marshal(m.Interface()) b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m.Interface())
if !nerr.Merge(err) { if !nerr.Merge(err) {
return err return err
} }

View File

@ -1327,7 +1327,7 @@ value: "some bytes"
OptString: scalar.String("inception"), OptString: scalar.String("inception"),
}, },
} }
b, err := proto.Marshal(m) b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
if err != nil { if err != nil {
t.Fatalf("error in binary marshaling message for Any.value: %v", err) t.Fatalf("error in binary marshaling message for Any.value: %v", err)
} }