@@ -184,14 +184,14 @@ func TestMarshal(t *testing.T) {
184184 assert .Equal (t , tc .platErr .MarshalCount + 1 , int (protoError .MarshalCount ))
185185
186186 if tc .platErr .IsRetryable == nil {
187- assert .False (t , protoError .Retryable . Value )
187+ assert .Nil (t , protoError .Retryable )
188188 } else {
189189 assert .Equal (t , * tc .platErr .IsRetryable , protoError .Retryable .Value )
190190 assert .Equal (t , tc .protoErr .Retryable .Value , protoError .Retryable .Value )
191191 }
192192
193193 if tc .platErr .IsUnexpected == nil {
194- assert .False (t , protoError .Unexpected . Value )
194+ assert .Nil (t , protoError .Unexpected )
195195 } else {
196196 assert .Equal (t , * tc .platErr .IsUnexpected , protoError .Unexpected .Value )
197197 assert .Equal (t , tc .protoErr .Unexpected .Value , protoError .Unexpected .Value )
@@ -200,6 +200,18 @@ func TestMarshal(t *testing.T) {
200200 if tc .platErr .MessageChain != nil {
201201 assert .Equal (t , tc .platErr .MessageChain , protoError .MessageChain )
202202 }
203+ t .Run ("unmarshalling again keeps the same values" , func (t * testing.T ) {
204+ roundTripped := Unmarshal (protoError )
205+ // The `Code` can change (e.g. to "unknown") so we cannot assert on this
206+ assert .Equal (t , tc .platErr .Message , roundTripped .Message )
207+ assert .Equal (t , tc .platErr .MessageChain , roundTripped .MessageChain )
208+
209+ assert .EqualValues (t , tc .platErr .IsRetryable , roundTripped .IsRetryable )
210+ assert .EqualValues (t , tc .platErr .IsUnexpected , roundTripped .IsUnexpected )
211+
212+ // The marshal count is incremented by 1 on every marshal
213+ assert .Equal (t , tc .platErr .MarshalCount + 1 , roundTripped .MarshalCount )
214+ })
203215 }
204216}
205217
0 commit comments