mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 19:21:19 +00:00
63 lines
1.1 KiB
Go
63 lines
1.1 KiB
Go
|
package testutil
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
pb "github.com/prysmaticlabs/prysm/proto/testing"
|
||
|
)
|
||
|
|
||
|
func TestOverrideSpecName(t *testing.T) {
|
||
|
input := struct {
|
||
|
Foo string `json:"foo"`
|
||
|
Baz string `json:"baz"`
|
||
|
}{
|
||
|
Foo: "foo",
|
||
|
Baz: "baz",
|
||
|
}
|
||
|
output := &pb.TestMessage{}
|
||
|
if err := ConvertToPb(input, output); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if output.Foo != "foo" {
|
||
|
t.Error("Expected output.Foo to be foo")
|
||
|
}
|
||
|
if output.Bar != "baz" {
|
||
|
t.Errorf("Expected output.Bar to be baz")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestOverrideSpecName_NestedProto(t *testing.T) {
|
||
|
input := struct {
|
||
|
Fuzz string `json:"fuzz"`
|
||
|
Msg struct {
|
||
|
Foo string `json:"foo"`
|
||
|
Baz string `json:"baz"`
|
||
|
}
|
||
|
}{
|
||
|
Fuzz: "fuzz",
|
||
|
Msg: struct {
|
||
|
Foo string `json:"foo"`
|
||
|
Baz string `json:"baz"`
|
||
|
}{
|
||
|
Foo: "foo",
|
||
|
Baz: "baz",
|
||
|
},
|
||
|
}
|
||
|
|
||
|
output := &pb.TestNestedMessage{}
|
||
|
if err := ConvertToPb(input, output); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if output.Fuzz != "fuzz" {
|
||
|
t.Error("Expected output.fuzz to be fuzz")
|
||
|
}
|
||
|
if output.Msg.Foo != "foo" {
|
||
|
t.Error("Expected output.Msg.Foo to be foo")
|
||
|
}
|
||
|
if output.Msg.Bar != "baz" {
|
||
|
t.Errorf("Expected output.Msg.Bar to be baz")
|
||
|
}
|
||
|
}
|