Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -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 devices |
| 18 | |
| 19 | import ( |
Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -0700 | [diff] [blame] | 20 | "testing" |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 21 | |
| 22 | "github.com/stretchr/testify/assert" |
Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -0700 | [diff] [blame] | 23 | ) |
| 24 | |
| 25 | func Test_Onu_CreateOnu(t *testing.T) { |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 26 | nextCtag := map[string]int{} |
| 27 | nextStag := map[string]int{} |
Mahir Gunyel | a1753ae | 2021-06-23 00:24:56 -0700 | [diff] [blame] | 28 | |
Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -0700 | [diff] [blame] | 29 | olt := OltDevice{ |
Andrea Campanella | 6f5f355 | 2022-03-10 17:14:25 +0100 | [diff] [blame^] | 30 | ID: 0, |
| 31 | NumUni: 4, |
| 32 | NumPots: 1, |
| 33 | NniDhcpTrapVid: 60, |
Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -0700 | [diff] [blame] | 34 | } |
| 35 | pon := PonPort{ |
| 36 | ID: 1, |
| 37 | Olt: &olt, |
| 38 | } |
| 39 | |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 40 | onu := CreateONU(&olt, &pon, 1, 0, nextCtag, nextStag, false) |
Matteo Scandolo | 378b8c9 | 2020-04-16 14:34:22 -0700 | [diff] [blame] | 41 | |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 42 | assert.Equal(t, "BBSM00000101", onu.Sn()) |
| 43 | assert.Equal(t, 4, len(onu.UniPorts)) |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 44 | assert.Equal(t, 1, len(onu.PotsPorts)) |
Andrea Campanella | 6f5f355 | 2022-03-10 17:14:25 +0100 | [diff] [blame^] | 45 | assert.Equal(t, 60, olt.NniDhcpTrapVid) |
| 46 | |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 47 | } |