Skip to content
Snippets Groups Projects
Commit fb9cd08b authored by Fabian Seidl's avatar Fabian Seidl
Browse files

fix generated test stub after merging changes from develop

parent 9a6ea08c
No related branches found
No related tags found
3 merge requests!376Add additional example application hostname-checker,!343Add basic application framework and example application to show interaction between events an NBI,!342Resolve "Add an option to send gNMI Subscribe requests via SBI"
Pipeline #110100 failed
...@@ -7,11 +7,13 @@ import ( ...@@ -7,11 +7,13 @@ import (
"testing" "testing"
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi" "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" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport" tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" "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/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/mocks" "code.fbi.h-da.de/danet/gosdn/controller/mocks"
...@@ -1208,70 +1210,58 @@ func Test_pndImplementation_saveGoStructsToFile(t *testing.T) { ...@@ -1208,70 +1210,58 @@ func Test_pndImplementation_saveGoStructsToFile(t *testing.T) {
} }
func Test_pndImplementation_SubscribePath(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 { type args struct {
uuid uuid.UUID uuid uuid.UUID
subList *ppb.SubscriptionList subList *ppb.SubscriptionList
rErr error
} }
tests := []struct { tests := []struct {
name string name string
fields fields
args args args args
wantErr bool wantErr bool
}{ }{
//TODO(faseid): Implement proper test here! //TODO(faseid): Implement proper test here!
// { // {
// name: "default", // name: "default",
// args: args{ // args: args{
// uuid: did, // uuid: did,
// subList: &ppb.SubscriptionList{ // subList: &ppb.SubscriptionList{
// Subscription: []*ppb.Subscription{ // Subscription: []*ppb.Subscription{
// { // {
// Path: "", // Path: "",
// StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE, // StreamMode: ppb.StreamMode_STREAM_MODE_SAMPLE,
// SampleInterval: 1000000000, // 1 second // SampleInterval: 1000000000, // 1 second
// }, // },
// }, // },
// Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM, // Mode: ppb.SubscriptionMode_SUBSCRIPTION_MODE_STREAM,
// }, // },
// }, // },
// }, // },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
sbiService := NewGenericService[southbound.SouthboundInterface]() pnd := &pndImplementation{
deviceService := NewGenericService[device.Device]() Name: tt.fields.Name,
Description: tt.fields.Description,
pnd := pndImplementation{ southboundService: tt.fields.southboundService,
Name: "default", deviceService: tt.fields.deviceService,
Description: "default test pnd", changes: tt.fields.changes,
southboundService: &sbiService, Id: tt.fields.Id,
deviceService: &deviceService, csbiClient: tt.fields.csbiClient,
changes: store.NewChangeStore(), callback: tt.fields.callback,
Id: defaultPndID, eventService: tt.fields.eventService,
}
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.addDevice(deviceWithMockTransport)
if err := pnd.SubscribePath(tt.args.uuid, tt.args.subList); (err != nil) != tt.wantErr { 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) t.Errorf("pndImplementation.SubscribePath() error = %v, wantErr %v", err, tt.wantErr)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment