mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
vendor files
This commit is contained in:
36
vendor/github.com/gogo/protobuf/test/jsonpb-gogo/jsonpb_gogo_test.go
generated
vendored
Normal file
36
vendor/github.com/gogo/protobuf/test/jsonpb-gogo/jsonpb_gogo_test.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
package jsonpb_gogo
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/jsonpb"
|
||||
)
|
||||
|
||||
// customFieldMessage implements protobuf.Message but is not a normal generated message type.
|
||||
type customFieldMessage struct {
|
||||
someField string //this is not a proto field
|
||||
}
|
||||
|
||||
func (m *customFieldMessage) Reset() {
|
||||
m.someField = "hello"
|
||||
}
|
||||
|
||||
func (m *customFieldMessage) String() string {
|
||||
return m.someField
|
||||
}
|
||||
|
||||
func (m *customFieldMessage) ProtoMessage() {
|
||||
}
|
||||
|
||||
func TestUnmarshalWithJSONPBUnmarshaler(t *testing.T) {
|
||||
rawJson := `{}`
|
||||
marshaler := &jsonpb.Marshaler{}
|
||||
msg := &customFieldMessage{someField: "Ignore me"}
|
||||
str, err := marshaler.MarshalToString(msg)
|
||||
if err != nil {
|
||||
t.Errorf("an unexpected error occurred when marshaling message: %v", err)
|
||||
}
|
||||
if str != rawJson {
|
||||
t.Errorf("marshaled JSON was incorrect: got %s, wanted %s", str, rawJson)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user