blob: 7056063474e80456eacddf73a4022381b65b6d04 [file] [log] [blame]
cbabua9e04cc2019-10-03 12:35:45 +05301/*
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
cbabubef89432019-10-18 11:47:27 +020017/*
18This file contains unit test cases for functions in the file openolt.go.
19This file also implements the fields struct to mock the Openolt and few utility functions.
20*/
21
Scott Bakerdbd960e2020-02-28 08:57:51 -080022//Package core provides the utility for olt devices, flows and statistics
23package core
cbabua9e04cc2019-10-03 12:35:45 +053024
25import (
26 "context"
27 "errors"
Kent Hagermanf1db18b2020-07-08 13:38:15 -040028 "reflect"
Kent Hagermanf1db18b2020-07-08 13:38:15 -040029 "testing"
30
Girish Gowdra4c3d4602021-07-22 16:33:37 -070031 conf "github.com/opencord/voltha-lib-go/v6/pkg/config"
serkant.uluderya7b8211e2021-02-24 16:39:18 +030032
Girish Gowdra4c3d4602021-07-22 16:33:37 -070033 com "github.com/opencord/voltha-lib-go/v6/pkg/adapters/common"
34 "github.com/opencord/voltha-lib-go/v6/pkg/events"
35 fu "github.com/opencord/voltha-lib-go/v6/pkg/flows"
36 "github.com/opencord/voltha-lib-go/v6/pkg/kafka"
37 "github.com/opencord/voltha-lib-go/v6/pkg/log"
Scott Bakerdbd960e2020-02-28 08:57:51 -080038 "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
Thomas Lee S94109f12020-03-03 16:39:29 +053039 "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
Girish Gowdraa09aeab2020-09-14 16:30:52 -070040 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
41 "github.com/opencord/voltha-protos/v4/go/openflow_13"
42 ofp "github.com/opencord/voltha-protos/v4/go/openflow_13"
43 "github.com/opencord/voltha-protos/v4/go/voltha"
cbabua9e04cc2019-10-03 12:35:45 +053044)
45
cbabubef89432019-10-18 11:47:27 +020046// mocks the OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053047type fields struct {
Kent Hagermane6ff1012020-07-14 15:07:53 -040048 deviceHandlers map[string]*DeviceHandler
49 coreProxy *com.CoreProxy
50 adapterProxy *com.AdapterProxy
Himani Chawlacd407802020-12-10 12:08:59 +053051 eventProxy *events.EventProxy
Kent Hagermane6ff1012020-07-14 15:07:53 -040052 kafkaICProxy kafka.InterContainerProxy
53 numOnus int
54 KVStoreAddress string
55 KVStoreType string
56 exitChannel chan int
57 ctx context.Context
cbabua9e04cc2019-10-03 12:35:45 +053058}
59
cbabubef89432019-10-18 11:47:27 +020060// mockOlt mocks OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053061func mockOlt() *fields {
cbabua9e04cc2019-10-03 12:35:45 +053062 dh := newMockDeviceHandler()
63 newOlt := &fields{}
64 newOlt.deviceHandlers = map[string]*DeviceHandler{}
65 newOlt.deviceHandlers[dh.device.Id] = dh
66 return newOlt
67}
68
cbabubef89432019-10-18 11:47:27 +020069// testOltObject maps fields type to OpenOLt type.
cbabua9e04cc2019-10-03 12:35:45 +053070func testOltObject(testOlt *fields) *OpenOLT {
71 return &OpenOLT{
72 deviceHandlers: testOlt.deviceHandlers,
73 coreProxy: testOlt.coreProxy,
74 adapterProxy: testOlt.adapterProxy,
75 eventProxy: testOlt.eventProxy,
76 kafkaICProxy: testOlt.kafkaICProxy,
77 numOnus: testOlt.numOnus,
Neha Sharma3f221ae2020-04-29 19:02:12 +000078 KVStoreAddress: testOlt.KVStoreAddress,
cbabua9e04cc2019-10-03 12:35:45 +053079 KVStoreType: testOlt.KVStoreType,
80 exitChannel: testOlt.exitChannel,
81 }
82}
83
cbabubef89432019-10-18 11:47:27 +020084// mockDevice mocks Device.
cbabua9e04cc2019-10-03 12:35:45 +053085func mockDevice() *voltha.Device {
Kent Hagermanf1db18b2020-07-08 13:38:15 -040086 return &voltha.Device{
cbabua9e04cc2019-10-03 12:35:45 +053087 Id: "olt",
88 Root: true,
89 ParentId: "logical_device",
cbabua9e04cc2019-10-03 12:35:45 +053090 ProxyAddress: &voltha.Device_ProxyAddress{
91 DeviceId: "olt",
92 DeviceType: "onu",
93 ChannelId: 1,
94 ChannelGroupId: 1,
95 },
96 ConnectStatus: 1,
97 }
cbabua9e04cc2019-10-03 12:35:45 +053098}
99
100func TestNewOpenOLT(t *testing.T) {
101 tests := []struct {
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530102 name string
103 fields *fields
104 configFlags *config.AdapterFlags
Matteo Scandolodfa7a972020-11-06 13:03:40 -0800105 cm *conf.ConfigManager
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530106 want *OpenOLT
cbabua9e04cc2019-10-03 12:35:45 +0530107 }{
serkant.uluderya7b8211e2021-02-24 16:39:18 +0300108 {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "etcd"}, &conf.ConfigManager{},
109 &OpenOLT{numOnus: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "etcd"}},
Matteo Scandolodfa7a972020-11-06 13:03:40 -0800110 {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}, &conf.ConfigManager{},
Neha Sharma3f221ae2020-04-29 19:02:12 +0000111 &OpenOLT{numOnus: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}},
cbabua9e04cc2019-10-03 12:35:45 +0530112 }
113 for _, tt := range tests {
114 t.Run(tt.name, func(t *testing.T) {
115 if got := NewOpenOLT(tt.fields.ctx, tt.fields.kafkaICProxy, tt.fields.coreProxy, tt.fields.adapterProxy,
Matteo Scandolodfa7a972020-11-06 13:03:40 -0800116 tt.fields.eventProxy, tt.configFlags, tt.cm); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
cbabua9e04cc2019-10-03 12:35:45 +0530117 t.Errorf("NewOpenOLT() error = %v, wantErr %v", got, tt.want)
118 }
119 })
120 }
121}
122
123func TestOpenOLT_Abandon_device(t *testing.T) {
124 type args struct {
125 device *voltha.Device
126 }
127 tests := []struct {
128 name string
129 fields *fields
130 args args
131 wantErr error
132 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530133 {"abandon_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
134 {"abandon_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
135 {"abandon_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530136 }
137 for _, tt := range tests {
138 t.Run(tt.name, func(t *testing.T) {
139 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000140 if err := oo.Abandon_device(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530141 t.Errorf("Abandon_device() error = %v, wantErr %v", err, tt.wantErr)
142 }
143 })
144 }
145}
146
147func TestOpenOLT_Activate_image_update(t *testing.T) {
148 type args struct {
149 device *voltha.Device
150 request *voltha.ImageDownload
151 }
152 tests := []struct {
153 name string
154 fields *fields
155 args args
156 want *voltha.ImageDownload
157 wantErr error
158 }{
159 {"activate_image_upate-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530160 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530161 {"activate_image_upate-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123CDE"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530162 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530163 {"activate_image_upate-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123EFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530164 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530165 }
166 for _, tt := range tests {
167 t.Run(tt.name, func(t *testing.T) {
168 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000169 got, err := oo.Activate_image_update(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800170 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530171 t.Errorf("Activate_image_update() error = %v, wantErr %v", err, tt.wantErr)
172 }
173 })
174 }
175}
176
177func TestOpenOLT_Adapter_descriptor(t *testing.T) {
178 tests := []struct {
179 name string
180 fields *fields
181 wantErr error
182 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530183 {"adapter_descriptor-1", &fields{}, olterrors.ErrNotImplemented},
184 {"adapter_descriptor-2", &fields{}, olterrors.ErrNotImplemented},
185 {"adapter_descriptor-3", &fields{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530186 }
187 for _, tt := range tests {
188 t.Run(tt.name, func(t *testing.T) {
189 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000190 if err := oo.Adapter_descriptor(context.Background()); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530191 t.Errorf("Adapter_descriptor() error = %v, wantErr %v", err, tt.wantErr)
192 }
193 })
194 }
195}
196
197func TestOpenOLT_Adopt_device(t *testing.T) {
198 type args struct {
199 device *voltha.Device
200 }
201 var device = mockDevice()
kesavand39e0aa32020-01-28 20:58:50 -0500202 device.Id = "olt"
Thomas Lee S94109f12020-03-03 16:39:29 +0530203 nilDevice := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530204 tests := []struct {
205 name string
206 fields *fields
207 args args
208 wantErr error
209 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800210 {"adopt_device-1", mockOlt(), args{}, nilDevice},
211 {"adopt_device-2", mockOlt(), args{device}, nilDevice},
212 {"adopt_device-3", mockOlt(), args{mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530213 }
214 for _, tt := range tests {
215 t.Run(tt.name, func(t *testing.T) {
216 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000217 err := oo.Adopt_device(context.Background(), tt.args.device)
cbabua9e04cc2019-10-03 12:35:45 +0530218 if (err != nil) && (reflect.TypeOf(err) !=
219 reflect.TypeOf(tt.wantErr)) && (tt.args.device == nil) {
220 t.Errorf("Adopt_device() error = %v, wantErr %v", err, tt.wantErr)
221 }
222 if err == nil {
223 t.Log("return'd nil")
224 }
225 })
226 }
227}
228
229func TestOpenOLT_Cancel_image_download(t *testing.T) {
230 type args struct {
231 device *voltha.Device
232 request *voltha.ImageDownload
233 }
234 tests := []struct {
235 name string
236 fields *fields
237 args args
238 want *voltha.ImageDownload
239 wantErr error
240 }{
241 {"cancel_image_download-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530242 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530243 {"cancel_image_download-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123IJK"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530244 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530245 {"cancel_image_download-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123KLM"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530246 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530247 }
248 for _, tt := range tests {
249 t.Run(tt.name, func(t *testing.T) {
250 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000251 got, err := oo.Cancel_image_download(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800252 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530253 t.Errorf("Cancel_image_download() error = %v, wantErr %v", err, tt.wantErr)
254 }
255 })
256 }
257}
258
259func TestOpenOLT_Delete_device(t *testing.T) {
260 type args struct {
261 device *voltha.Device
262 }
263 tests := []struct {
264 name string
265 fields *fields
266 args args
267 wantErr error
268 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800269 {"delete_device-1", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530270 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530271 }
272 for _, tt := range tests {
273 t.Run(tt.name, func(t *testing.T) {
274 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000275 if err := oo.Delete_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530276 t.Errorf("Delete_device() error = %v, wantErr %v", err, tt.wantErr)
277 }
278 })
279 }
280}
281
282func TestOpenOLT_Device_types(t *testing.T) {
283 tests := []struct {
284 name string
285 fields *fields
286 want *voltha.DeviceTypes
287 wantErr error
288 }{
289 {"device_types-1", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530290 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530291 {"device_types-2", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530292 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530293 {"device_types-3", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530294 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530295 }
296 for _, tt := range tests {
297 t.Run(tt.name, func(t *testing.T) {
298 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000299 got, err := oo.Device_types(context.Background())
David K. Bainbridge794735f2020-02-11 21:01:37 -0800300 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530301 t.Errorf("Device_types() error = %v, wantErr %v", err, tt.wantErr)
302 }
303 })
304 }
305}
306
307func TestOpenOLT_Disable_device(t *testing.T) {
308 type args struct {
309 device *voltha.Device
310 }
311 tests := []struct {
312 name string
313 fields *fields
314 args args
315 wantErr error
316 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800317 {"disable_device-1", mockOlt(), args{mockDevice()}, nil},
318 {"disable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530319 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530320 }
321 for _, tt := range tests {
322 t.Run(tt.name, func(t *testing.T) {
323 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000324 if err := oo.Disable_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530325 t.Errorf("Disable_device() error = %v, wantErr %v", err, tt.wantErr)
326 }
327 })
328 }
329}
330
331func TestOpenOLT_Download_image(t *testing.T) {
332 type args struct {
333 device *voltha.Device
334 request *voltha.ImageDownload
335 }
336 tests := []struct {
337 name string
338 fields *fields
339 args args
340 want *voltha.ImageDownload
341 wantErr error
342 }{
343 {"download_image-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530344 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530345 {"download_image-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530346 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530347 {"download_image-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123RTY"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530348 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530349 }
350 for _, tt := range tests {
351 t.Run(tt.name, func(t *testing.T) {
352 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000353 got, err := oo.Download_image(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800354 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530355 t.Errorf("Download_image() error = %v, wantErr %v", err, tt.wantErr)
356 }
357 })
358 }
359}
360
361func TestOpenOLT_Get_device_details(t *testing.T) {
362 type args struct {
363 device *voltha.Device
364 }
365 tests := []struct {
366 name string
367 fields *fields
368 args args
369 wantErr error
370 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530371 {"get_device_details-1", &fields{}, args{}, olterrors.ErrNotImplemented},
372 {"get_device_details-2", &fields{}, args{}, olterrors.ErrNotImplemented},
373 {"get_device_details-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530374 }
375 for _, tt := range tests {
376 t.Run(tt.name, func(t *testing.T) {
377 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000378 if err := oo.Get_device_details(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530379 t.Errorf("Get_device_details() error = %v, wantErr %v", err, tt.wantErr)
380 }
381 })
382 }
383}
384
385func TestOpenOLT_Get_image_download_status(t *testing.T) {
386 type args struct {
387 device *voltha.Device
388 request *voltha.ImageDownload
389 }
390 tests := []struct {
391 name string
392 fields *fields
393 args args
394 want *voltha.ImageDownload
395 wantErr error
396 }{
397 {"get_image_download_status-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530398 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530399 {"get_image_download_status-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530400 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530401 {"get_image_download_status-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123DFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530402 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530403 }
404 for _, tt := range tests {
405 t.Run(tt.name, func(t *testing.T) {
406 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000407 got, err := oo.Get_image_download_status(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800408 if err != tt.wantErr && got == nil {
409 t.Errorf("Get_image_download_status() got = %v want = %v error = %v, wantErr %v",
410 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530411 }
412 })
413 }
414}
415
416func TestOpenOLT_Get_ofp_device_info(t *testing.T) {
417 type args struct {
418 device *voltha.Device
419 }
420 tests := []struct {
421 name string
422 fields *fields
423 args args
424 want *ic.SwitchCapability
425 wantErr error
426 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800427 {"get_ofp_device_info-1", mockOlt(), args{mockDevice()}, &ic.SwitchCapability{
428 Desc: &openflow_13.OfpDesc{
429 MfrDesc: "VOLTHA Project",
430 HwDesc: "open_pon",
431 SwDesc: "open_pon",
432 },
433 SwitchFeatures: &openflow_13.OfpSwitchFeatures{
434 NBuffers: uint32(256),
435 NTables: uint32(2),
436 Capabilities: uint32(15),
437 },
438 }, nil},
439 {"get_ofp_device_info-2", &fields{}, args{mockDevice()}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530440 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530441 }
442 for _, tt := range tests {
443 t.Run(tt.name, func(t *testing.T) {
444 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000445 got, err := oo.Get_ofp_device_info(context.Background(), tt.args.device)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800446 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
447 t.Errorf("Get_ofp_device_info() got = %v want = %v error = %v, wantErr = %v",
448 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530449 }
450 })
451 }
452}
453
cbabua9e04cc2019-10-03 12:35:45 +0530454func TestOpenOLT_Health(t *testing.T) {
455 tests := []struct {
456 name string
457 fields *fields
458 want *voltha.HealthStatus
459 wantErr error
460 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530461 {"health-1", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
462 {"health-2", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
463 {"health-3", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530464 }
465 for _, tt := range tests {
466 t.Run(tt.name, func(t *testing.T) {
467 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000468 got, err := oo.Health(context.Background())
David K. Bainbridge794735f2020-02-11 21:01:37 -0800469 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530470 t.Errorf("Get_ofp_port_info() error = %v, wantErr %v", err, tt.wantErr)
471 }
472 })
473 }
474}
475
476func TestOpenOLT_Process_inter_adapter_message(t *testing.T) {
477 type args struct {
478 msg *ic.InterAdapterMessage
479 }
480 var message1 = args{
481 msg: &ic.InterAdapterMessage{
482 Header: &ic.InterAdapterHeader{
483 Id: "olt",
484 ProxyDeviceId: "",
485 ToDeviceId: "onu1",
486 },
487 },
488 }
489 var message2 = args{
490 msg: &ic.InterAdapterMessage{
491 Header: &ic.InterAdapterHeader{
492 Id: "olt",
493 ProxyDeviceId: "olt",
494 ToDeviceId: "olt",
David K. Bainbridge794735f2020-02-11 21:01:37 -0800495 Type: ic.InterAdapterMessageType_OMCI_REQUEST,
496 },
497 },
498 }
499 var message3 = args{
500 msg: &ic.InterAdapterMessage{
501 Header: &ic.InterAdapterHeader{
502 Id: "olt",
503 ProxyDeviceId: "olt",
504 ToDeviceId: "olt",
505 Type: ic.InterAdapterMessageType_FLOW_REQUEST,
cbabua9e04cc2019-10-03 12:35:45 +0530506 },
507 },
508 }
509 tests := []struct {
David K. Bainbridge794735f2020-02-11 21:01:37 -0800510 name string
511 fields *fields
512 args args
513 wantErrType reflect.Type
cbabua9e04cc2019-10-03 12:35:45 +0530514 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800515 {"process_inter_adaptor_messgae-1", mockOlt(), message1,
Thomas Lee S94109f12020-03-03 16:39:29 +0530516 reflect.TypeOf(&olterrors.ErrNotFound{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800517 {"process_inter_adaptor_messgae-2", mockOlt(), message2,
Girish Kumarf26e4882020-03-05 06:49:10 +0000518 reflect.TypeOf(&olterrors.ErrAdapter{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800519 {"process_inter_adaptor_messgae-3", mockOlt(), message3,
Thomas Lee S94109f12020-03-03 16:39:29 +0530520 reflect.TypeOf(&olterrors.ErrInvalidValue{})},
cbabua9e04cc2019-10-03 12:35:45 +0530521 }
522 for _, tt := range tests {
523 t.Run(tt.name, func(t *testing.T) {
524 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000525 if err := oo.Process_inter_adapter_message(context.Background(), tt.args.msg); reflect.TypeOf(err) != tt.wantErrType {
David K. Bainbridge794735f2020-02-11 21:01:37 -0800526 t.Errorf("Process_inter_adapter_message() error = %v, wantErr %v",
527 reflect.TypeOf(err), tt.wantErrType)
cbabua9e04cc2019-10-03 12:35:45 +0530528 }
529 })
530 }
531}
532
533func TestOpenOLT_Reboot_device(t *testing.T) {
534 type args struct {
535 device *voltha.Device
536 }
537 tests := []struct {
538 name string
539 fields *fields
540 args args
541 wantErr error
542 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800543 {"reboot_device-1", mockOlt(), args{mockDevice()}, nil},
544 {"reboot_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530545 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530546 }
547 for _, tt := range tests {
548 t.Run(tt.name, func(t *testing.T) {
549 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000550 if err := oo.Reboot_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530551 t.Errorf("Reboot_device() error = %v, wantErr %v", err, tt.wantErr)
552 }
553 })
554 }
555}
556
557func TestOpenOLT_Receive_packet_out(t *testing.T) {
558 acts := []*ofp.OfpAction{
559 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
560 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
561 fu.Output(1),
562 }
563 type args struct {
564 deviceID string
565 egressPortNo int
566 packet *openflow_13.OfpPacketOut
567 }
568 pktout := &ofp.OfpPacketOut{BufferId: 0, InPort: 1, Actions: acts, Data: []byte("AYDCAAAOAODsSE5TiMwCBwQA4OxITlIEBQUwLzUx" +
569 "BgIAFAgEMC81MQoJbG9jYWxob3N0EBwFAawbqqACAAAAoRAxLjMuNi4xLjQuMS40NDEz/gYAgMILAgD+GQCAwgkDAAAAAGQAAAAAAAAAAgICAgICAgL+" +
570 "GQCAwgoDAAAAAGQAAAAAAAAAAgICAgICAgIAAA==")}
571 tests := []struct {
572 name string
573 fields *fields
574 args args
575 wantErr error
576 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800577 {"receive_packet_out-1", mockOlt(), args{mockDevice().Id, 1, pktout}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530578 {"receive_packet_out-2", mockOlt(), args{"1234", 1, pktout},
Thomas Lee S94109f12020-03-03 16:39:29 +0530579 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "1234"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530580 }
581 for _, tt := range tests {
582 t.Run(tt.name, func(t *testing.T) {
583 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000584 if err := oo.Receive_packet_out(context.Background(), tt.args.deviceID, tt.args.egressPortNo, tt.args.packet); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530585 t.Errorf("Receive_packet_out() error = %v, wantErr %v", err, tt.wantErr)
586 }
587 })
588 }
589}
590
591func TestOpenOLT_Reconcile_device(t *testing.T) {
592 type args struct {
593 device *voltha.Device
594 }
Thomas Lee S94109f12020-03-03 16:39:29 +0530595 expectedError := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530596 tests := []struct {
597 name string
598 fields *fields
599 args args
600 wantErr error
601 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800602 {"reconcile_device-1", &fields{}, args{}, expectedError},
603 {"reconcile_device-2", &fields{}, args{}, expectedError},
604 {"reconcile_device-3", &fields{}, args{}, expectedError},
cbabua9e04cc2019-10-03 12:35:45 +0530605 }
606 for _, tt := range tests {
607 t.Run(tt.name, func(t *testing.T) {
608 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000609 if err := oo.Reconcile_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530610 t.Errorf("Reconcile_device() error = %v, wantErr %v", err, tt.wantErr)
611 }
612 })
613 }
614}
615
616func TestOpenOLT_Reenable_device(t *testing.T) {
617 type args struct {
618 device *voltha.Device
619 }
620 tests := []struct {
621 name string
622 fields *fields
623 args args
624 wantErr error
625 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800626 {"reenable_device-1", mockOlt(), args{mockDevice()}, nil},
627 {"reenable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530628 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530629 }
630 for _, tt := range tests {
631 t.Run(tt.name, func(t *testing.T) {
632 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000633 if err := oo.Reenable_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530634 t.Errorf("Reenable_device() error = %v, wantErr %v", err, tt.wantErr)
635 }
636 })
637 }
638}
639
640func TestOpenOLT_Revert_image_update(t *testing.T) {
641 type args struct {
642 device *voltha.Device
643 request *voltha.ImageDownload
644 }
645 tests := []struct {
646 name string
647 fields *fields
648 args args
649 want *voltha.ImageDownload
650 wantErr error
651 }{
652 {"revert_image_update-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530653 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530654 {"revert_image_update-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123TYU"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530655 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530656 {"revert_image_update-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123GTH"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530657 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530658 }
659 for _, tt := range tests {
660 t.Run(tt.name, func(t *testing.T) {
661 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000662 got, err := oo.Revert_image_update(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800663 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530664 t.Log("error :", err)
665 }
666 })
667 }
668}
669
670func TestOpenOLT_Self_test_device(t *testing.T) {
671 type args struct {
672 device *voltha.Device
673 }
674 tests := []struct {
675 name string
676 fields *fields
677 args args
678 wantErr error
679 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530680 {"self_test_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
681 {"self_test_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
682 {"self_test_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530683 }
684 for _, tt := range tests {
685 t.Run(tt.name, func(t *testing.T) {
686 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000687 if err := oo.Self_test_device(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530688 t.Errorf("Self_test_device() error = %v, wantErr %v", err, tt.wantErr)
689 }
690 })
691 }
692}
693
694func TestOpenOLT_Start(t *testing.T) {
695 type args struct {
696 ctx context.Context
697 }
698 tests := []struct {
699 name string
700 fields *fields
701 args args
702 wantErr error
703 }{
704 {"start-1", &fields{}, args{}, errors.New("start error")},
705 }
706 for _, tt := range tests {
707 t.Run(tt.name, func(t *testing.T) {
708 oo := testOltObject(tt.fields)
709 if err := oo.Start(tt.args.ctx); err != nil {
710 t.Errorf("Start() error = %v, wantErr %v", err, tt.wantErr)
711 }
712 })
713 }
714}
715
716func TestOpenOLT_Stop(t *testing.T) {
717 type args struct {
718 ctx context.Context
719 }
720 tests := []struct {
721 name string
722 fields *fields
723 args args
724 wantErr error
725 }{
726 {"stop-1", &fields{exitChannel: make(chan int, 1)}, args{}, errors.New("stop error")},
727 }
728 for _, tt := range tests {
729 t.Run(tt.name, func(t *testing.T) {
730 oo := testOltObject(tt.fields)
Kent Hagermane6ff1012020-07-14 15:07:53 -0400731 if err := oo.Start(tt.args.ctx); err != nil {
732 t.Error(err)
733 }
cbabua9e04cc2019-10-03 12:35:45 +0530734 if err := oo.Stop(tt.args.ctx); err != nil {
735 t.Errorf("Stop() error = %v, wantErr %v", err, tt.wantErr)
736 }
737 })
738 }
739}
740
Devmalya Pauldd23a992019-11-14 07:06:31 +0000741func TestOpenOLT_Suppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530742 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000743 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530744 }
745 tests := []struct {
746 name string
747 fields *fields
748 args args
749 wantErr error
750 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530751 {"suppress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
752 {"suppress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
753 {"suppress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530754 }
755 for _, tt := range tests {
756 t.Run(tt.name, func(t *testing.T) {
757 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000758 if err := oo.Suppress_event(context.Background(), tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000759 t.Errorf("Suppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530760 }
761 })
762 }
763}
764
Devmalya Pauldd23a992019-11-14 07:06:31 +0000765func TestOpenOLT_Unsuppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530766 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000767 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530768 }
769 tests := []struct {
770 name string
771 fields *fields
772 args args
773 wantErr error
774 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530775 {"unsupress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
776 {"unsupress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
777 {"unsupress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530778 }
779 for _, tt := range tests {
780 t.Run(tt.name, func(t *testing.T) {
781 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000782 if err := oo.Unsuppress_event(context.Background(), tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000783 t.Errorf("Unsuppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530784 }
785 })
786 }
787}
788
789func TestOpenOLT_Update_flows_bulk(t *testing.T) {
790 type args struct {
791 device *voltha.Device
792 flows *voltha.Flows
793 groups *voltha.FlowGroups
794 flowMetadata *voltha.FlowMetadata
795 }
796 tests := []struct {
797 name string
798 fields *fields
799 args args
800 wantErr error
801 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530802 {"update_flows_bulk-1", &fields{}, args{}, olterrors.ErrNotImplemented},
803 {"update_flows_bulk-2", &fields{}, args{}, olterrors.ErrNotImplemented},
804 {"update_flows_bulk-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530805 }
806 for _, tt := range tests {
807 t.Run(tt.name, func(t *testing.T) {
808 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000809 if err := oo.Update_flows_bulk(context.Background(), tt.args.device, tt.args.flows, tt.args.groups, tt.args.flowMetadata); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530810 t.Errorf("Update_flows_bulk() error = %v, wantErr %v", err, tt.wantErr)
811 }
812 })
813 }
814}
815
816func TestOpenOLT_Update_flows_incrementally(t *testing.T) {
817 type args struct {
818 device *voltha.Device
819 flows *openflow_13.FlowChanges
820 groups *openflow_13.FlowGroupChanges
821 flowMetadata *voltha.FlowMetadata
822 }
823
824 tests := []struct {
825 name string
826 fields *fields
827 args args
828 wantErr error
829 }{
830 {"update_flows_incrementally-1", &fields{}, args{device: mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530831 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800832 {"update_flows_incrementally-2", mockOlt(), args{device: mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530833 }
834 for _, tt := range tests {
835 t.Run(tt.name, func(t *testing.T) {
836 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000837 if err := oo.Update_flows_incrementally(context.Background(), tt.args.device, tt.args.flows, tt.args.groups, tt.args.flowMetadata); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530838 t.Errorf("Update_flows_incrementally() error = %v, wantErr %v", err, tt.wantErr)
839 }
840 })
841 }
842}
843
844func TestOpenOLT_Update_pm_config(t *testing.T) {
845 type args struct {
846 device *voltha.Device
847 pmConfigs *voltha.PmConfigs
848 }
849 tests := []struct {
850 name string
851 fields *fields
852 args args
853 wantErr error
854 }{
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000855 {"update_pm_config-1", mockOlt(), args{device: mockDevice(), pmConfigs: &voltha.PmConfigs{DefaultFreq: 150, Grouped: false, FreqOverride: false}}, nil},
856 {"update_pm_config-2", &fields{}, args{device: mockDevice(), pmConfigs: &voltha.PmConfigs{DefaultFreq: 150, Grouped: false, FreqOverride: false}}, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530857 }
858 for _, tt := range tests {
859 t.Run(tt.name, func(t *testing.T) {
860 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000861
862 if err := oo.Update_pm_config(context.Background(), tt.args.device, tt.args.pmConfigs); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530863 t.Errorf("Update_pm_config() error = %v, wantErr %v", err, tt.wantErr)
864 }
865
866 })
867 }
868}
869
870func TestOpenOLT_deleteDeviceHandlerToMap(t *testing.T) {
871 type args struct {
872 agent *DeviceHandler
873 }
874 tests := []struct {
875 name string
876 fields *fields
877 args args
878 }{
879 {"delete_device_handler_map-1", mockOlt(), args{newMockDeviceHandler()}},
880 }
881 for _, tt := range tests {
882 t.Run(tt.name, func(t *testing.T) {
883 oo := testOltObject(tt.fields)
884 oo.deleteDeviceHandlerToMap(tt.args.agent)
885 if len(oo.deviceHandlers) > 0 {
886 t.Errorf("delete device manager failed")
887 }
888 })
889 }
890}
kesavand39e0aa32020-01-28 20:58:50 -0500891
892func TestOpenOLT_Enable_port(t *testing.T) {
893 type args struct {
894 deviceID string
895 port *voltha.Port
896 }
897 tests := []struct {
898 name string
899 fields *fields
900 args args
901 wantErr bool
902 }{
903 // TODO: Add test cases.
904 {"Enable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
905 {"Enable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
906 }
907 for _, tt := range tests {
908 t.Run(tt.name, func(t *testing.T) {
909 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000910 if err := oo.Enable_port(context.Background(), tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
kesavand39e0aa32020-01-28 20:58:50 -0500911 t.Errorf("OpenOLT.Enable_port() error = %v, wantErr %v", err, tt.wantErr)
912 }
913 })
914 }
915}
916
917func TestOpenOLT_Disable_port(t *testing.T) {
918 type args struct {
919 deviceID string
920 port *voltha.Port
921 }
922 tests := []struct {
923 name string
924 fields *fields
925 args args
926 wantErr bool
927 }{
928 // TODO: Add test cases.
929 {"Disable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
930 {"Disable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
931 }
932 for _, tt := range tests {
933 t.Run(tt.name, func(t *testing.T) {
934 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000935 if err := oo.Disable_port(context.Background(), tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
kesavand39e0aa32020-01-28 20:58:50 -0500936 t.Errorf("OpenOLT.Disable_port() error = %v, wantErr %v", err, tt.wantErr)
937 }
938 })
939 }
940}