Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net) |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 3 | * Copyright 2020-present Open Networking Foundation |
| 4 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 5 | * 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 Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 8 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 10 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 11 | * 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 Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 16 | */ |
| 17 | package omci_test |
| 18 | |
| 19 | import ( |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 20 | . "github.com/opencord/omci-lib-go" |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 21 | "github.com/google/gopacket" |
| 22 | "github.com/google/gopacket/layers" |
| 23 | "github.com/stretchr/testify/assert" |
| 24 | "testing" |
| 25 | ) |
| 26 | |
| 27 | var buffer []byte |
| 28 | |
| 29 | func 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 | |
| 46 | func TestNextIsNil(t *testing.T) { |
| 47 | mock := simpleMock(t) |
| 48 | assert.Equal(t, mock.NextLayerType(), gopacket.LayerTypeZero) |
| 49 | } |
| 50 | |
| 51 | func TestPayloadAlwaysNil(t *testing.T) { |
| 52 | mock := simpleMock(t) |
| 53 | assert.Nil(t, mock.LayerPayload()) |
| 54 | } |
| 55 | |
| 56 | func TestMsgCanBeDecoded(t *testing.T) { |
| 57 | mock := simpleMock(t) |
| 58 | assert.Equal(t, mock.CanDecode(), mock.MsgLayerType) |
| 59 | } |