Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | |
| 17 | package omci |
| 18 | |
| 19 | import ( |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 20 | "testing" |
| 21 | |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 22 | "github.com/opencord/omci-lib-go/v2" |
| 23 | me "github.com/opencord/omci-lib-go/v2/generated" |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 24 | "github.com/stretchr/testify/assert" |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | func TestSetRequest(t *testing.T) { |
| 28 | |
| 29 | meId := GenerateUniPortEntityId(1) |
| 30 | |
| 31 | meParams := me.ParamData{ |
| 32 | EntityID: meId.ToUint16(), |
| 33 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 34 | me.UniG_AdministrativeState: 1, |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 35 | }, |
| 36 | } |
| 37 | meInstance, omciError := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 38 | if omciError.GetError() != nil { |
| 39 | t.Fatal(omciError.GetError()) |
| 40 | } |
| 41 | |
| 42 | pkt, err := CreateSetRequest(meInstance, 1) |
| 43 | assert.NoError(t, err) |
| 44 | |
| 45 | omciPkt, omciMsg, err := ParseOpenOltOmciPacket(pkt) |
| 46 | assert.NoError(t, err) |
| 47 | assert.Equal(t, omciMsg.MessageType, omci.SetRequestType) |
| 48 | |
| 49 | msgObj, _ := ParseSetRequest(omciPkt) |
| 50 | |
| 51 | assert.Equal(t, meId.ToUint16(), msgObj.EntityInstance) |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 52 | assert.Equal(t, uint8(1), msgObj.Attributes[me.UniG_AdministrativeState]) |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 53 | |
| 54 | } |