diff --git a/controller/nucleus/principalNetworkDomain_test.go b/controller/nucleus/principalNetworkDomain_test.go index b9cf3b5e83bc3a09e35a676cf2bf11c085bfc89d..03ebce168efd57b0d21be2ffaabec57dd64fe25a 100644 --- a/controller/nucleus/principalNetworkDomain_test.go +++ b/controller/nucleus/principalNetworkDomain_test.go @@ -7,11 +7,13 @@ import ( "testing" "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" + cpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" + eventInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" "code.fbi.h-da.de/danet/gosdn/controller/mocks" @@ -1208,70 +1210,58 @@ func Test_pndImplementation_saveGoStructsToFile(t *testing.T) { } func Test_pndImplementation_SubscribePath(t *testing.T) { + type fields struct { + Name string + Description string + southboundService southbound.Service + deviceService device.Service + changes *store.ChangeStore + Id uuid.UUID + csbiClient cpb.CsbiServiceClient + callback func(uuid.UUID, chan device.Details) + eventService eventInterfaces.Service + } type args struct { uuid uuid.UUID subList *ppb.SubscriptionList - rErr error } tests := []struct { name string + fields fields args args wantErr bool }{ //TODO(faseid): Implement proper test here! // { - // name: "default", - // args: args{ - // uuid: did, - // subList: &ppb.SubscriptionList{ - // Subscription: []*ppb.Subscription{ - // { - // Path: "", - // StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, - // SampleInterval: 1000000000, // 1 second - // }, - // }, - // Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, - // }, - // }, + // name: "default", + // args: args{ + // uuid: did, + // subList: &ppb.SubscriptionList{ + // Subscription: []*ppb.Subscription{ + // { + // Path: "", + // StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, + // SampleInterval: 1000000000, // 1 second + // }, + // }, + // Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, + // }, + // }, // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - sbiService := NewGenericService[southbound.SouthboundInterface]() - deviceService := NewGenericService[device.Device]() - - pnd := pndImplementation{ - Name: "default", - Description: "default test pnd", - southboundService: &sbiService, - deviceService: &deviceService, - changes: store.NewChangeStore(), - Id: defaultPndID, - } - - sbi, err := NewSBI(spb.Type_TYPE_OPENCONFIG) - if err != nil { - t.Error("could not create sbi") - } - - err = pnd.addSbi(sbi) - if err != nil { - t.Error("could not add sbi") - } - - transport := mocks.Transport{} - transport.On("Subscribe", mockContext, mock.Anything).Return(&gpb.SubscribeResponse{}, tt.args.rErr) - - deviceWithMockTransport := &CommonDevice{ - UUID: mdid, - Model: &openconfig.Device{}, - sbi: sbi, - transport: &transport, + pnd := &pndImplementation{ + Name: tt.fields.Name, + Description: tt.fields.Description, + southboundService: tt.fields.southboundService, + deviceService: tt.fields.deviceService, + changes: tt.fields.changes, + Id: tt.fields.Id, + csbiClient: tt.fields.csbiClient, + callback: tt.fields.callback, + eventService: tt.fields.eventService, } - - _, _ = pnd.addDevice(deviceWithMockTransport) - if err := pnd.SubscribePath(tt.args.uuid, tt.args.subList); (err != nil) != tt.wantErr { t.Errorf("pndImplementation.SubscribePath() error = %v, wantErr %v", err, tt.wantErr) }