blob: 08c2f528f9c56fed5031bf5b307fb03ecee06401 [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
Esin Karamanccb714b2019-11-29 15:02:06 +000031 com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
32 fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
33 "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
David K. Bainbridge794735f2020-02-11 21:01:37 -080034 "github.com/opencord/voltha-lib-go/v3/pkg/log"
Scott Bakerdbd960e2020-02-28 08:57:51 -080035 "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
Thomas Lee S94109f12020-03-03 16:39:29 +053036 "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
Esin Karamanccb714b2019-11-29 15:02:06 +000037 ic "github.com/opencord/voltha-protos/v3/go/inter_container"
38 "github.com/opencord/voltha-protos/v3/go/openflow_13"
39 ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
40 "github.com/opencord/voltha-protos/v3/go/voltha"
cbabua9e04cc2019-10-03 12:35:45 +053041)
42
cbabubef89432019-10-18 11:47:27 +020043// mocks the OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053044type fields struct {
Kent Hagermane6ff1012020-07-14 15:07:53 -040045 deviceHandlers map[string]*DeviceHandler
46 coreProxy *com.CoreProxy
47 adapterProxy *com.AdapterProxy
48 eventProxy *com.EventProxy
49 kafkaICProxy kafka.InterContainerProxy
50 numOnus int
51 KVStoreAddress string
52 KVStoreType string
53 exitChannel chan int
54 ctx context.Context
cbabua9e04cc2019-10-03 12:35:45 +053055}
56
cbabubef89432019-10-18 11:47:27 +020057// mockOlt mocks OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053058func mockOlt() *fields {
cbabua9e04cc2019-10-03 12:35:45 +053059 dh := newMockDeviceHandler()
60 newOlt := &fields{}
61 newOlt.deviceHandlers = map[string]*DeviceHandler{}
62 newOlt.deviceHandlers[dh.device.Id] = dh
63 return newOlt
64}
65
cbabubef89432019-10-18 11:47:27 +020066// testOltObject maps fields type to OpenOLt type.
cbabua9e04cc2019-10-03 12:35:45 +053067func testOltObject(testOlt *fields) *OpenOLT {
68 return &OpenOLT{
69 deviceHandlers: testOlt.deviceHandlers,
70 coreProxy: testOlt.coreProxy,
71 adapterProxy: testOlt.adapterProxy,
72 eventProxy: testOlt.eventProxy,
73 kafkaICProxy: testOlt.kafkaICProxy,
74 numOnus: testOlt.numOnus,
Neha Sharma3f221ae2020-04-29 19:02:12 +000075 KVStoreAddress: testOlt.KVStoreAddress,
cbabua9e04cc2019-10-03 12:35:45 +053076 KVStoreType: testOlt.KVStoreType,
77 exitChannel: testOlt.exitChannel,
78 }
79}
80
cbabubef89432019-10-18 11:47:27 +020081// mockDevice mocks Device.
cbabua9e04cc2019-10-03 12:35:45 +053082func mockDevice() *voltha.Device {
Kent Hagermanf1db18b2020-07-08 13:38:15 -040083 return &voltha.Device{
cbabua9e04cc2019-10-03 12:35:45 +053084 Id: "olt",
85 Root: true,
86 ParentId: "logical_device",
cbabua9e04cc2019-10-03 12:35:45 +053087 ProxyAddress: &voltha.Device_ProxyAddress{
88 DeviceId: "olt",
89 DeviceType: "onu",
90 ChannelId: 1,
91 ChannelGroupId: 1,
92 },
93 ConnectStatus: 1,
94 }
cbabua9e04cc2019-10-03 12:35:45 +053095}
96
97func TestNewOpenOLT(t *testing.T) {
98 tests := []struct {
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +053099 name string
100 fields *fields
101 configFlags *config.AdapterFlags
102 want *OpenOLT
cbabua9e04cc2019-10-03 12:35:45 +0530103 }{
Neha Sharma3f221ae2020-04-29 19:02:12 +0000104 {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"},
105 &OpenOLT{numOnus: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"}},
106 {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"},
107 &OpenOLT{numOnus: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}},
108 {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"},
109 &OpenOLT{numOnus: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"}},
cbabua9e04cc2019-10-03 12:35:45 +0530110 }
111 for _, tt := range tests {
112 t.Run(tt.name, func(t *testing.T) {
113 if got := NewOpenOLT(tt.fields.ctx, tt.fields.kafkaICProxy, tt.fields.coreProxy, tt.fields.adapterProxy,
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530114 tt.fields.eventProxy, tt.configFlags); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
cbabua9e04cc2019-10-03 12:35:45 +0530115 t.Errorf("NewOpenOLT() error = %v, wantErr %v", got, tt.want)
116 }
117 })
118 }
119}
120
121func TestOpenOLT_Abandon_device(t *testing.T) {
122 type args struct {
123 device *voltha.Device
124 }
125 tests := []struct {
126 name string
127 fields *fields
128 args args
129 wantErr error
130 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530131 {"abandon_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
132 {"abandon_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
133 {"abandon_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530134 }
135 for _, tt := range tests {
136 t.Run(tt.name, func(t *testing.T) {
137 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000138 if err := oo.Abandon_device(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530139 t.Errorf("Abandon_device() error = %v, wantErr %v", err, tt.wantErr)
140 }
141 })
142 }
143}
144
145func TestOpenOLT_Activate_image_update(t *testing.T) {
146 type args struct {
147 device *voltha.Device
148 request *voltha.ImageDownload
149 }
150 tests := []struct {
151 name string
152 fields *fields
153 args args
154 want *voltha.ImageDownload
155 wantErr error
156 }{
157 {"activate_image_upate-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530158 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530159 {"activate_image_upate-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123CDE"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530160 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530161 {"activate_image_upate-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123EFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530162 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530163 }
164 for _, tt := range tests {
165 t.Run(tt.name, func(t *testing.T) {
166 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000167 got, err := oo.Activate_image_update(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800168 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530169 t.Errorf("Activate_image_update() error = %v, wantErr %v", err, tt.wantErr)
170 }
171 })
172 }
173}
174
175func TestOpenOLT_Adapter_descriptor(t *testing.T) {
176 tests := []struct {
177 name string
178 fields *fields
179 wantErr error
180 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530181 {"adapter_descriptor-1", &fields{}, olterrors.ErrNotImplemented},
182 {"adapter_descriptor-2", &fields{}, olterrors.ErrNotImplemented},
183 {"adapter_descriptor-3", &fields{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530184 }
185 for _, tt := range tests {
186 t.Run(tt.name, func(t *testing.T) {
187 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000188 if err := oo.Adapter_descriptor(context.Background()); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530189 t.Errorf("Adapter_descriptor() error = %v, wantErr %v", err, tt.wantErr)
190 }
191 })
192 }
193}
194
195func TestOpenOLT_Adopt_device(t *testing.T) {
196 type args struct {
197 device *voltha.Device
198 }
199 var device = mockDevice()
kesavand39e0aa32020-01-28 20:58:50 -0500200 device.Id = "olt"
Thomas Lee S94109f12020-03-03 16:39:29 +0530201 nilDevice := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530202 tests := []struct {
203 name string
204 fields *fields
205 args args
206 wantErr error
207 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800208 {"adopt_device-1", mockOlt(), args{}, nilDevice},
209 {"adopt_device-2", mockOlt(), args{device}, nilDevice},
210 {"adopt_device-3", mockOlt(), args{mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530211 }
212 for _, tt := range tests {
213 t.Run(tt.name, func(t *testing.T) {
214 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000215 err := oo.Adopt_device(context.Background(), tt.args.device)
cbabua9e04cc2019-10-03 12:35:45 +0530216 if (err != nil) && (reflect.TypeOf(err) !=
217 reflect.TypeOf(tt.wantErr)) && (tt.args.device == nil) {
218 t.Errorf("Adopt_device() error = %v, wantErr %v", err, tt.wantErr)
219 }
220 if err == nil {
221 t.Log("return'd nil")
222 }
223 })
224 }
225}
226
227func TestOpenOLT_Cancel_image_download(t *testing.T) {
228 type args struct {
229 device *voltha.Device
230 request *voltha.ImageDownload
231 }
232 tests := []struct {
233 name string
234 fields *fields
235 args args
236 want *voltha.ImageDownload
237 wantErr error
238 }{
239 {"cancel_image_download-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530240 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530241 {"cancel_image_download-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123IJK"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530242 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530243 {"cancel_image_download-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123KLM"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530244 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530245 }
246 for _, tt := range tests {
247 t.Run(tt.name, func(t *testing.T) {
248 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000249 got, err := oo.Cancel_image_download(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800250 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530251 t.Errorf("Cancel_image_download() error = %v, wantErr %v", err, tt.wantErr)
252 }
253 })
254 }
255}
256
257func TestOpenOLT_Delete_device(t *testing.T) {
258 type args struct {
259 device *voltha.Device
260 }
261 tests := []struct {
262 name string
263 fields *fields
264 args args
265 wantErr error
266 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800267 {"delete_device-1", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530268 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530269 }
270 for _, tt := range tests {
271 t.Run(tt.name, func(t *testing.T) {
272 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000273 if err := oo.Delete_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530274 t.Errorf("Delete_device() error = %v, wantErr %v", err, tt.wantErr)
275 }
276 })
277 }
278}
279
280func TestOpenOLT_Device_types(t *testing.T) {
281 tests := []struct {
282 name string
283 fields *fields
284 want *voltha.DeviceTypes
285 wantErr error
286 }{
287 {"device_types-1", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530288 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530289 {"device_types-2", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530290 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530291 {"device_types-3", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530292 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530293 }
294 for _, tt := range tests {
295 t.Run(tt.name, func(t *testing.T) {
296 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000297 got, err := oo.Device_types(context.Background())
David K. Bainbridge794735f2020-02-11 21:01:37 -0800298 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530299 t.Errorf("Device_types() error = %v, wantErr %v", err, tt.wantErr)
300 }
301 })
302 }
303}
304
305func TestOpenOLT_Disable_device(t *testing.T) {
306 type args struct {
307 device *voltha.Device
308 }
309 tests := []struct {
310 name string
311 fields *fields
312 args args
313 wantErr error
314 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800315 {"disable_device-1", mockOlt(), args{mockDevice()}, nil},
316 {"disable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530317 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530318 }
319 for _, tt := range tests {
320 t.Run(tt.name, func(t *testing.T) {
321 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000322 if err := oo.Disable_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530323 t.Errorf("Disable_device() error = %v, wantErr %v", err, tt.wantErr)
324 }
325 })
326 }
327}
328
329func TestOpenOLT_Download_image(t *testing.T) {
330 type args struct {
331 device *voltha.Device
332 request *voltha.ImageDownload
333 }
334 tests := []struct {
335 name string
336 fields *fields
337 args args
338 want *voltha.ImageDownload
339 wantErr error
340 }{
341 {"download_image-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530342 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530343 {"download_image-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530344 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530345 {"download_image-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123RTY"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530346 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530347 }
348 for _, tt := range tests {
349 t.Run(tt.name, func(t *testing.T) {
350 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000351 got, err := oo.Download_image(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800352 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530353 t.Errorf("Download_image() error = %v, wantErr %v", err, tt.wantErr)
354 }
355 })
356 }
357}
358
359func TestOpenOLT_Get_device_details(t *testing.T) {
360 type args struct {
361 device *voltha.Device
362 }
363 tests := []struct {
364 name string
365 fields *fields
366 args args
367 wantErr error
368 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530369 {"get_device_details-1", &fields{}, args{}, olterrors.ErrNotImplemented},
370 {"get_device_details-2", &fields{}, args{}, olterrors.ErrNotImplemented},
371 {"get_device_details-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530372 }
373 for _, tt := range tests {
374 t.Run(tt.name, func(t *testing.T) {
375 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000376 if err := oo.Get_device_details(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530377 t.Errorf("Get_device_details() error = %v, wantErr %v", err, tt.wantErr)
378 }
379 })
380 }
381}
382
383func TestOpenOLT_Get_image_download_status(t *testing.T) {
384 type args struct {
385 device *voltha.Device
386 request *voltha.ImageDownload
387 }
388 tests := []struct {
389 name string
390 fields *fields
391 args args
392 want *voltha.ImageDownload
393 wantErr error
394 }{
395 {"get_image_download_status-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530396 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530397 {"get_image_download_status-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530398 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530399 {"get_image_download_status-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123DFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530400 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530401 }
402 for _, tt := range tests {
403 t.Run(tt.name, func(t *testing.T) {
404 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000405 got, err := oo.Get_image_download_status(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800406 if err != tt.wantErr && got == nil {
407 t.Errorf("Get_image_download_status() got = %v want = %v error = %v, wantErr %v",
408 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530409 }
410 })
411 }
412}
413
414func TestOpenOLT_Get_ofp_device_info(t *testing.T) {
415 type args struct {
416 device *voltha.Device
417 }
418 tests := []struct {
419 name string
420 fields *fields
421 args args
422 want *ic.SwitchCapability
423 wantErr error
424 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800425 {"get_ofp_device_info-1", mockOlt(), args{mockDevice()}, &ic.SwitchCapability{
426 Desc: &openflow_13.OfpDesc{
427 MfrDesc: "VOLTHA Project",
428 HwDesc: "open_pon",
429 SwDesc: "open_pon",
430 },
431 SwitchFeatures: &openflow_13.OfpSwitchFeatures{
432 NBuffers: uint32(256),
433 NTables: uint32(2),
434 Capabilities: uint32(15),
435 },
436 }, nil},
437 {"get_ofp_device_info-2", &fields{}, args{mockDevice()}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530438 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530439 }
440 for _, tt := range tests {
441 t.Run(tt.name, func(t *testing.T) {
442 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000443 got, err := oo.Get_ofp_device_info(context.Background(), tt.args.device)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800444 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
445 t.Errorf("Get_ofp_device_info() got = %v want = %v error = %v, wantErr = %v",
446 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530447 }
448 })
449 }
450}
451
cbabua9e04cc2019-10-03 12:35:45 +0530452func TestOpenOLT_Health(t *testing.T) {
453 tests := []struct {
454 name string
455 fields *fields
456 want *voltha.HealthStatus
457 wantErr error
458 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530459 {"health-1", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
460 {"health-2", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
461 {"health-3", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530462 }
463 for _, tt := range tests {
464 t.Run(tt.name, func(t *testing.T) {
465 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000466 got, err := oo.Health(context.Background())
David K. Bainbridge794735f2020-02-11 21:01:37 -0800467 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530468 t.Errorf("Get_ofp_port_info() error = %v, wantErr %v", err, tt.wantErr)
469 }
470 })
471 }
472}
473
474func TestOpenOLT_Process_inter_adapter_message(t *testing.T) {
475 type args struct {
476 msg *ic.InterAdapterMessage
477 }
478 var message1 = args{
479 msg: &ic.InterAdapterMessage{
480 Header: &ic.InterAdapterHeader{
481 Id: "olt",
482 ProxyDeviceId: "",
483 ToDeviceId: "onu1",
484 },
485 },
486 }
487 var message2 = args{
488 msg: &ic.InterAdapterMessage{
489 Header: &ic.InterAdapterHeader{
490 Id: "olt",
491 ProxyDeviceId: "olt",
492 ToDeviceId: "olt",
David K. Bainbridge794735f2020-02-11 21:01:37 -0800493 Type: ic.InterAdapterMessageType_OMCI_REQUEST,
494 },
495 },
496 }
497 var message3 = args{
498 msg: &ic.InterAdapterMessage{
499 Header: &ic.InterAdapterHeader{
500 Id: "olt",
501 ProxyDeviceId: "olt",
502 ToDeviceId: "olt",
503 Type: ic.InterAdapterMessageType_FLOW_REQUEST,
cbabua9e04cc2019-10-03 12:35:45 +0530504 },
505 },
506 }
507 tests := []struct {
David K. Bainbridge794735f2020-02-11 21:01:37 -0800508 name string
509 fields *fields
510 args args
511 wantErrType reflect.Type
cbabua9e04cc2019-10-03 12:35:45 +0530512 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800513 {"process_inter_adaptor_messgae-1", mockOlt(), message1,
Thomas Lee S94109f12020-03-03 16:39:29 +0530514 reflect.TypeOf(&olterrors.ErrNotFound{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800515 {"process_inter_adaptor_messgae-2", mockOlt(), message2,
Girish Kumarf26e4882020-03-05 06:49:10 +0000516 reflect.TypeOf(&olterrors.ErrAdapter{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800517 {"process_inter_adaptor_messgae-3", mockOlt(), message3,
Thomas Lee S94109f12020-03-03 16:39:29 +0530518 reflect.TypeOf(&olterrors.ErrInvalidValue{})},
cbabua9e04cc2019-10-03 12:35:45 +0530519 }
520 for _, tt := range tests {
521 t.Run(tt.name, func(t *testing.T) {
522 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000523 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 -0800524 t.Errorf("Process_inter_adapter_message() error = %v, wantErr %v",
525 reflect.TypeOf(err), tt.wantErrType)
cbabua9e04cc2019-10-03 12:35:45 +0530526 }
527 })
528 }
529}
530
531func TestOpenOLT_Reboot_device(t *testing.T) {
532 type args struct {
533 device *voltha.Device
534 }
535 tests := []struct {
536 name string
537 fields *fields
538 args args
539 wantErr error
540 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800541 {"reboot_device-1", mockOlt(), args{mockDevice()}, nil},
542 {"reboot_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530543 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530544 }
545 for _, tt := range tests {
546 t.Run(tt.name, func(t *testing.T) {
547 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000548 if err := oo.Reboot_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530549 t.Errorf("Reboot_device() error = %v, wantErr %v", err, tt.wantErr)
550 }
551 })
552 }
553}
554
555func TestOpenOLT_Receive_packet_out(t *testing.T) {
556 acts := []*ofp.OfpAction{
557 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
558 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
559 fu.Output(1),
560 }
561 type args struct {
562 deviceID string
563 egressPortNo int
564 packet *openflow_13.OfpPacketOut
565 }
566 pktout := &ofp.OfpPacketOut{BufferId: 0, InPort: 1, Actions: acts, Data: []byte("AYDCAAAOAODsSE5TiMwCBwQA4OxITlIEBQUwLzUx" +
567 "BgIAFAgEMC81MQoJbG9jYWxob3N0EBwFAawbqqACAAAAoRAxLjMuNi4xLjQuMS40NDEz/gYAgMILAgD+GQCAwgkDAAAAAGQAAAAAAAAAAgICAgICAgL+" +
568 "GQCAwgoDAAAAAGQAAAAAAAAAAgICAgICAgIAAA==")}
569 tests := []struct {
570 name string
571 fields *fields
572 args args
573 wantErr error
574 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800575 {"receive_packet_out-1", mockOlt(), args{mockDevice().Id, 1, pktout}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530576 {"receive_packet_out-2", mockOlt(), args{"1234", 1, pktout},
Thomas Lee S94109f12020-03-03 16:39:29 +0530577 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "1234"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530578 }
579 for _, tt := range tests {
580 t.Run(tt.name, func(t *testing.T) {
581 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000582 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 +0530583 t.Errorf("Receive_packet_out() error = %v, wantErr %v", err, tt.wantErr)
584 }
585 })
586 }
587}
588
589func TestOpenOLT_Reconcile_device(t *testing.T) {
590 type args struct {
591 device *voltha.Device
592 }
Thomas Lee S94109f12020-03-03 16:39:29 +0530593 expectedError := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530594 tests := []struct {
595 name string
596 fields *fields
597 args args
598 wantErr error
599 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800600 {"reconcile_device-1", &fields{}, args{}, expectedError},
601 {"reconcile_device-2", &fields{}, args{}, expectedError},
602 {"reconcile_device-3", &fields{}, args{}, expectedError},
cbabua9e04cc2019-10-03 12:35:45 +0530603 }
604 for _, tt := range tests {
605 t.Run(tt.name, func(t *testing.T) {
606 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000607 if err := oo.Reconcile_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530608 t.Errorf("Reconcile_device() error = %v, wantErr %v", err, tt.wantErr)
609 }
610 })
611 }
612}
613
614func TestOpenOLT_Reenable_device(t *testing.T) {
615 type args struct {
616 device *voltha.Device
617 }
618 tests := []struct {
619 name string
620 fields *fields
621 args args
622 wantErr error
623 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800624 {"reenable_device-1", mockOlt(), args{mockDevice()}, nil},
625 {"reenable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530626 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530627 }
628 for _, tt := range tests {
629 t.Run(tt.name, func(t *testing.T) {
630 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000631 if err := oo.Reenable_device(context.Background(), tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530632 t.Errorf("Reenable_device() error = %v, wantErr %v", err, tt.wantErr)
633 }
634 })
635 }
636}
637
638func TestOpenOLT_Revert_image_update(t *testing.T) {
639 type args struct {
640 device *voltha.Device
641 request *voltha.ImageDownload
642 }
643 tests := []struct {
644 name string
645 fields *fields
646 args args
647 want *voltha.ImageDownload
648 wantErr error
649 }{
650 {"revert_image_update-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530651 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530652 {"revert_image_update-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123TYU"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530653 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530654 {"revert_image_update-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123GTH"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530655 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530656 }
657 for _, tt := range tests {
658 t.Run(tt.name, func(t *testing.T) {
659 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000660 got, err := oo.Revert_image_update(context.Background(), tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800661 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530662 t.Log("error :", err)
663 }
664 })
665 }
666}
667
668func TestOpenOLT_Self_test_device(t *testing.T) {
669 type args struct {
670 device *voltha.Device
671 }
672 tests := []struct {
673 name string
674 fields *fields
675 args args
676 wantErr error
677 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530678 {"self_test_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
679 {"self_test_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
680 {"self_test_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530681 }
682 for _, tt := range tests {
683 t.Run(tt.name, func(t *testing.T) {
684 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000685 if err := oo.Self_test_device(context.Background(), tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530686 t.Errorf("Self_test_device() error = %v, wantErr %v", err, tt.wantErr)
687 }
688 })
689 }
690}
691
692func TestOpenOLT_Start(t *testing.T) {
693 type args struct {
694 ctx context.Context
695 }
696 tests := []struct {
697 name string
698 fields *fields
699 args args
700 wantErr error
701 }{
702 {"start-1", &fields{}, args{}, errors.New("start error")},
703 }
704 for _, tt := range tests {
705 t.Run(tt.name, func(t *testing.T) {
706 oo := testOltObject(tt.fields)
707 if err := oo.Start(tt.args.ctx); err != nil {
708 t.Errorf("Start() error = %v, wantErr %v", err, tt.wantErr)
709 }
710 })
711 }
712}
713
714func TestOpenOLT_Stop(t *testing.T) {
715 type args struct {
716 ctx context.Context
717 }
718 tests := []struct {
719 name string
720 fields *fields
721 args args
722 wantErr error
723 }{
724 {"stop-1", &fields{exitChannel: make(chan int, 1)}, args{}, errors.New("stop error")},
725 }
726 for _, tt := range tests {
727 t.Run(tt.name, func(t *testing.T) {
728 oo := testOltObject(tt.fields)
Kent Hagermane6ff1012020-07-14 15:07:53 -0400729 if err := oo.Start(tt.args.ctx); err != nil {
730 t.Error(err)
731 }
cbabua9e04cc2019-10-03 12:35:45 +0530732 if err := oo.Stop(tt.args.ctx); err != nil {
733 t.Errorf("Stop() error = %v, wantErr %v", err, tt.wantErr)
734 }
735 })
736 }
737}
738
Devmalya Pauldd23a992019-11-14 07:06:31 +0000739func TestOpenOLT_Suppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530740 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000741 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530742 }
743 tests := []struct {
744 name string
745 fields *fields
746 args args
747 wantErr error
748 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530749 {"suppress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
750 {"suppress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
751 {"suppress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530752 }
753 for _, tt := range tests {
754 t.Run(tt.name, func(t *testing.T) {
755 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000756 if err := oo.Suppress_event(context.Background(), tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000757 t.Errorf("Suppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530758 }
759 })
760 }
761}
762
Devmalya Pauldd23a992019-11-14 07:06:31 +0000763func TestOpenOLT_Unsuppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530764 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000765 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530766 }
767 tests := []struct {
768 name string
769 fields *fields
770 args args
771 wantErr error
772 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530773 {"unsupress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
774 {"unsupress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
775 {"unsupress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530776 }
777 for _, tt := range tests {
778 t.Run(tt.name, func(t *testing.T) {
779 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000780 if err := oo.Unsuppress_event(context.Background(), tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000781 t.Errorf("Unsuppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530782 }
783 })
784 }
785}
786
787func TestOpenOLT_Update_flows_bulk(t *testing.T) {
788 type args struct {
789 device *voltha.Device
790 flows *voltha.Flows
791 groups *voltha.FlowGroups
792 flowMetadata *voltha.FlowMetadata
793 }
794 tests := []struct {
795 name string
796 fields *fields
797 args args
798 wantErr error
799 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530800 {"update_flows_bulk-1", &fields{}, args{}, olterrors.ErrNotImplemented},
801 {"update_flows_bulk-2", &fields{}, args{}, olterrors.ErrNotImplemented},
802 {"update_flows_bulk-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530803 }
804 for _, tt := range tests {
805 t.Run(tt.name, func(t *testing.T) {
806 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000807 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 +0530808 t.Errorf("Update_flows_bulk() error = %v, wantErr %v", err, tt.wantErr)
809 }
810 })
811 }
812}
813
814func TestOpenOLT_Update_flows_incrementally(t *testing.T) {
815 type args struct {
816 device *voltha.Device
817 flows *openflow_13.FlowChanges
818 groups *openflow_13.FlowGroupChanges
819 flowMetadata *voltha.FlowMetadata
820 }
821
822 tests := []struct {
823 name string
824 fields *fields
825 args args
826 wantErr error
827 }{
828 {"update_flows_incrementally-1", &fields{}, args{device: mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530829 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800830 {"update_flows_incrementally-2", mockOlt(), args{device: mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530831 }
832 for _, tt := range tests {
833 t.Run(tt.name, func(t *testing.T) {
834 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000835 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 +0530836 t.Errorf("Update_flows_incrementally() error = %v, wantErr %v", err, tt.wantErr)
837 }
838 })
839 }
840}
841
842func TestOpenOLT_Update_pm_config(t *testing.T) {
843 type args struct {
844 device *voltha.Device
845 pmConfigs *voltha.PmConfigs
846 }
847 tests := []struct {
848 name string
849 fields *fields
850 args args
851 wantErr error
852 }{
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000853 {"update_pm_config-1", mockOlt(), args{device: mockDevice(), pmConfigs: &voltha.PmConfigs{DefaultFreq: 150, Grouped: false, FreqOverride: false}}, nil},
854 {"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 +0530855 }
856 for _, tt := range tests {
857 t.Run(tt.name, func(t *testing.T) {
858 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000859
860 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 +0530861 t.Errorf("Update_pm_config() error = %v, wantErr %v", err, tt.wantErr)
862 }
863
864 })
865 }
866}
867
868func TestOpenOLT_deleteDeviceHandlerToMap(t *testing.T) {
869 type args struct {
870 agent *DeviceHandler
871 }
872 tests := []struct {
873 name string
874 fields *fields
875 args args
876 }{
877 {"delete_device_handler_map-1", mockOlt(), args{newMockDeviceHandler()}},
878 }
879 for _, tt := range tests {
880 t.Run(tt.name, func(t *testing.T) {
881 oo := testOltObject(tt.fields)
882 oo.deleteDeviceHandlerToMap(tt.args.agent)
883 if len(oo.deviceHandlers) > 0 {
884 t.Errorf("delete device manager failed")
885 }
886 })
887 }
888}
kesavand39e0aa32020-01-28 20:58:50 -0500889
890func TestOpenOLT_Enable_port(t *testing.T) {
891 type args struct {
892 deviceID string
893 port *voltha.Port
894 }
895 tests := []struct {
896 name string
897 fields *fields
898 args args
899 wantErr bool
900 }{
901 // TODO: Add test cases.
902 {"Enable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
903 {"Enable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
904 }
905 for _, tt := range tests {
906 t.Run(tt.name, func(t *testing.T) {
907 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000908 if err := oo.Enable_port(context.Background(), tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
kesavand39e0aa32020-01-28 20:58:50 -0500909 t.Errorf("OpenOLT.Enable_port() error = %v, wantErr %v", err, tt.wantErr)
910 }
911 })
912 }
913}
914
915func TestOpenOLT_Disable_port(t *testing.T) {
916 type args struct {
917 deviceID string
918 port *voltha.Port
919 }
920 tests := []struct {
921 name string
922 fields *fields
923 args args
924 wantErr bool
925 }{
926 // TODO: Add test cases.
927 {"Disable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
928 {"Disable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
929 }
930 for _, tt := range tests {
931 t.Run(tt.name, func(t *testing.T) {
932 oo := testOltObject(tt.fields)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000933 if err := oo.Disable_port(context.Background(), tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
kesavand39e0aa32020-01-28 20:58:50 -0500934 t.Errorf("OpenOLT.Disable_port() error = %v, wantErr %v", err, tt.wantErr)
935 }
936 })
937 }
938}