blob: 0e2b0c4573e204524f38f01294aafc36967333bb [file] [log] [blame]
Chip Boling6e27b352020-02-14 09:10:01 -06001/*
2 * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net)
Andrea Campanella7167ebb2020-02-24 09:56:38 +01003 * Copyright 2020-present Open Networking Foundation
4
Chip Boling6e27b352020-02-14 09:10:01 -06005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Andrea Campanella7167ebb2020-02-24 09:56:38 +01008
Chip Boling6e27b352020-02-14 09:10:01 -06009 * http://www.apache.org/licenses/LICENSE-2.0
Andrea Campanella7167ebb2020-02-24 09:56:38 +010010
Chip Boling6e27b352020-02-14 09:10:01 -060011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
Chip Boling6e27b352020-02-14 09:10:01 -060016 */
17package omci_test
18
19import (
Andrea Campanella7167ebb2020-02-24 09:56:38 +010020 . "github.com/opencord/omci-lib-go"
Chip Boling6e27b352020-02-14 09:10:01 -060021 "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}