MarshalAny is a convenience function to marshal protobuf messages into any protos. function will fail the test with a fatal error if the marshaling fails.
(t *testing.T, m proto.Message)
| 27 | // MarshalAny is a convenience function to marshal protobuf messages into any |
| 28 | // protos. function will fail the test with a fatal error if the marshaling fails. |
| 29 | func MarshalAny(t *testing.T, m proto.Message) *anypb.Any { |
| 30 | t.Helper() |
| 31 | |
| 32 | a, err := anypb.New(m) |
| 33 | if err != nil { |
| 34 | t.Fatalf("Failed to marshal proto %+v into an Any: %v", m, err) |
| 35 | } |
| 36 | return a |
| 37 | } |