diff --git a/northbound/server/pnd_test.go b/northbound/server/pnd_test.go index 6e0483ce28f394a3b4d9f2c07e86666461304a24..0f8767850c8caed05a9e4cb2938f4e41dd2a7d01 100644 --- a/northbound/server/pnd_test.go +++ b/northbound/server/pnd_test.go @@ -1,10 +1,13 @@ package server import ( + "context" "os" + "reflect" "testing" "time" + pb "code.fbi.h-da.de/danet/api/go/gosdn/core" ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound" "code.fbi.h-da.de/danet/api/go/gosdn/transport" @@ -171,59 +174,52 @@ func TestMain(m *testing.M) { func Test_pnd_Get(t *testing.T) { removeExistingStores() - // type args struct { - // ctx context.Context - // request *ppb.GetRequest - // } - // tests := []struct { - // name string - // args args - // want []string - // wantErr bool - // }{ - // { - // name: "get pnd", - // args: args{ - // ctx: context.Background(), - // request: &ppb.GetRequest{ - // Request: &ppb.GetRequest_Pnd{ - // Pnd: &ppb.GetPnd{}, - // }, - // Pid: pndID, - // }, - // }, - // want: []string{ - // pndID, - // ondID, - // sbiID, - // // pendingChangeID, - // // committedChangeID, - // }, - // }, - // } - // for _, tt := range tests { - // t.Run(tt.name, func(t *testing.T) { - // p := pndServer{ - // UnimplementedPndServiceServer: ppb.UnimplementedPndServiceServer{}, - // } - // resp, err := p.Get(tt.args.ctx, tt.args.request) - // if (err != nil) != tt.wantErr { - // t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr) - // return - // } + type args struct { + ctx context.Context + request *pb.GetPndRequest + } + tests := []struct { + name string + args args + want pb.GetPndResponse + wantErr bool + }{ + { + name: "get pnd", + args: args{ + ctx: context.Background(), + request: &pb.GetPndRequest{ + Pid: []string{ + pndID}, + }, + }, + want: pb.GetPndResponse{ + Pnd: []*ppb.PrincipalNetworkDomain{ + {Id: pndID, + Name: "test", + Description: "test"}, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + p := core{ + UnimplementedCoreServiceServer: pb.UnimplementedCoreServiceServer{}, + } + resp, err := p.GetPnd(tt.args.ctx, tt.args.request) + if (err != nil) != tt.wantErr { + t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr) + return + } - // got := []string{ - // resp.Pnd.Id, - // resp.Pnd.Ond[0].Id, - // resp.Pnd.Sbi[0].Id, - // // resp.Pnd.Change[0].Id, - // // resp.Pnd.Change[1].Id, - // } - // if !reflect.DeepEqual(got, tt.want) { - // t.Errorf("Get() got = %v, want %v", got, tt.want) - // } - // }) - // } + got := resp.GetPnd() + + if !reflect.DeepEqual(got, tt.want.Pnd) { + t.Errorf("Get() got = %v, want %v", got, tt.want.Pnd) + } + }) + } } func Test_pnd_Set(t *testing.T) {