Просмотр исходного кода

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>
Herbie Ong 6 лет назад
Родитель
Сommit
e0cf15babe
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      encoding/textpb/decode.go
  2. 1 1
      encoding/textpb/decode_test.go

+ 1 - 1
encoding/textpb/decode.go

@@ -486,7 +486,7 @@ func (o UnmarshalOptions) unmarshalAny(tfield [2]text.Value, knownFields pref.Kn
 		return err
 	}
 	// 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) {
 		return err
 	}

+ 1 - 1
encoding/textpb/decode_test.go

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