diff options
author | 2020-06-23 14:10:53 +0200 | |
---|---|---|
committer | 2020-06-24 08:17:33 +0200 | |
commit | ceed73403bdb61387d04be8b47183e9c4a970749 (patch) | |
tree | 3f48a49051672efb44945b279b9f69693bc48540 /codec/msg_codec_test.go | |
parent | 94620e85f0bdbb054af07ce3670fadc1f76cfdf0 (diff) |
Fix codec fallback and generate type imports
Change-Id: Idd76c7f19d952939caf153928ac60175845078ff
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'codec/msg_codec_test.go')
-rw-r--r-- | codec/msg_codec_test.go | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go index bf0695d..7f06f0f 100644 --- a/codec/msg_codec_test.go +++ b/codec/msg_codec_test.go @@ -4,12 +4,9 @@ import ( "bytes" "testing" - "github.com/lunixbochs/struc" - "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/codec" "git.fd.io/govpp.git/examples/binapi/ip" - "git.fd.io/govpp.git/examples/binapi/sr" "git.fd.io/govpp.git/examples/binapi/vpe" ) @@ -36,11 +33,11 @@ func TestEncode(t *testing.T) { msgID uint16 expData []byte }{ - /*{name: "basic", + {name: "basic", msg: &MyMsg{Index: 1, Label: []byte("Abcdef"), Port: 1000}, msgID: 100, expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8}, - },*/ + }, {name: "show version", msg: &vpe.ShowVersion{}, msgID: 743, @@ -55,32 +52,10 @@ func TestEncode(t *testing.T) { StatsIndex: 0, Prefix: ip.Prefix{}, NPaths: 0, - Paths: []ip.FibPath{ - { - SwIfIndex: 0, - TableID: 0, - RpfID: 0, - Weight: 0, - Preference: 0, - Type: 0, - Flags: 0, - Proto: 0, - Nh: ip.FibPathNh{}, - NLabels: 5, - LabelStack: [16]ip.FibMplsLabel{ - { - IsUniform: 1, - Label: 2, - TTL: 3, - Exp: 4, - }, - }, - }, - }, }, }, msgID: 743, - expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + expData: []byte{0x02, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }, /*{name: "sr", msg: &sr.SrPolicyAdd{ @@ -97,8 +72,7 @@ func TestEncode(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - c := &codec.MsgCodec{} - //c := &codec.NewCodec{} + c := codec.DefaultCodec data, err := c.EncodeMsg(test.msg, test.msgID) if err != nil { @@ -112,7 +86,7 @@ func TestEncode(t *testing.T) { } func TestEncodePanic(t *testing.T) { - c := &codec.MsgCodec{} + c := codec.DefaultCodec msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000} @@ -121,16 +95,3 @@ func TestEncodePanic(t *testing.T) { t.Fatalf("expected non-nil error, got: %v", err) } } - -func TestEncodeSr(t *testing.T) { - msg := sr.Srv6SidList{ - NumSids: 0, - Weight: 0, - //Sids: nil, - } - buf := new(bytes.Buffer) - - if err := struc.Pack(buf, msg); err != nil { - t.Fatal(err) - } -} |