blob: 7a4245f9eb774bed4a117def59b9272c3d414945 [file] [log] [blame]
Chip Boling6e27b352020-02-14 09:10:01 -06001/*
2 * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package omci_test
18
19import (
20 . "github.com/cboling/omci"
21 "github.com/google/gopacket"
22 "github.com/google/gopacket/layers"
23 "github.com/stretchr/testify/assert"
24 "testing"
25)
26
27var buffer []byte
28
29func simpleMock(t *testing.T) *MeBasePacket {
30 mibResetRequest := "00014F0A000200000000000000000000" +
31 "00000000000000000000000000000000" +
32 "000000000000000000000028"
33 data, err := stringToPacket(mibResetRequest)
34 assert.Nil(t, err)
35 assert.NotNil(t, data)
36
37 return &MeBasePacket{
38 EntityClass: 0x02,
39 EntityInstance: 0x00,
40 Layer: nil,
41 BaseLayer: layers.BaseLayer{},
42 MsgLayerType: LayerTypeMibResetRequest,
43 }
44}
45
46func TestNextIsNil(t *testing.T) {
47 mock := simpleMock(t)
48 assert.Equal(t, mock.NextLayerType(), gopacket.LayerTypeZero)
49}
50
51func TestPayloadAlwaysNil(t *testing.T) {
52 mock := simpleMock(t)
53 assert.Nil(t, mock.LayerPayload())
54}
55
56func TestMsgCanBeDecoded(t *testing.T) {
57 mock := simpleMock(t)
58 assert.Equal(t, mock.CanDecode(), mock.MsgLayerType)
59}