Skip to content
Snippets Groups Projects
Commit 5e187d37 authored by Malte Bauch's avatar Malte Bauch
Browse files

adapted the testcase blueprints

parent be368991
Branches
Tags
3 merge requests!97Resolve "PND handling via CLI and database",!91"Overhaul Architecture",!90Develop
Pipeline #63815 passed with warnings
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
func TestDevice_Add(t *testing.T) { func TestDevice_Add(t *testing.T) {
type fields struct { type fields struct {
Device ygot.GoStruct ygot.GoStruct
SBI SouthboundInterface SBI SouthboundInterface
Config DeviceConfig Config DeviceConfig
Transport Transport Transport Transport
...@@ -26,7 +26,7 @@ func TestDevice_Add(t *testing.T) { ...@@ -26,7 +26,7 @@ func TestDevice_Add(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
d := Device{ d := Device{
Device: tt.fields.Device, GoStruct: tt.fields.SBI.Schema().Root,
SBI: tt.fields.SBI, SBI: tt.fields.SBI,
Config: tt.fields.Config, Config: tt.fields.Config,
Transport: tt.fields.Transport, Transport: tt.fields.Transport,
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
func TestNewPND(t *testing.T) { func TestNewPND(t *testing.T) {
type args struct { type args struct {
name string name string
desc string
sbi SouthboundInterface sbi SouthboundInterface
} }
tests := []struct { tests := []struct {
...@@ -20,7 +21,7 @@ func TestNewPND(t *testing.T) { ...@@ -20,7 +21,7 @@ func TestNewPND(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if got := NewPND(tt.args.name, tt.args.sbi); !reflect.DeepEqual(got, tt.want) { if got := NewPND(tt.args.name, tt.args.desc, tt.args.sbi); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewPND() = %v, want %v", got, tt.want) t.Errorf("NewPND() = %v, want %v", got, tt.want)
} }
}) })
...@@ -28,15 +29,32 @@ func TestNewPND(t *testing.T) { ...@@ -28,15 +29,32 @@ func TestNewPND(t *testing.T) {
} }
func Test_addSbi(t *testing.T) { func Test_addSbi(t *testing.T) {
type fields struct {
name string
desc string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]*Device
}
type args struct {
sbi SouthboundInterface
}
tests := []struct { tests := []struct {
name string name string
fields fields
args args
wantErr bool wantErr bool
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if err := addSbi(); (err != nil) != tt.wantErr { pnd := &pndImplementation{
name: tt.fields.name,
description: tt.fields.desc,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.addSbi(tt.args.sbi); (err != nil) != tt.wantErr {
t.Errorf("addSbi() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("addSbi() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
...@@ -62,8 +80,9 @@ func Test_destroy(t *testing.T) { ...@@ -62,8 +80,9 @@ func Test_destroy(t *testing.T) {
func Test_pndImplementation_AddDevice(t *testing.T) { func Test_pndImplementation_AddDevice(t *testing.T) {
type fields struct { type fields struct {
name string name string
desc string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
} }
type args struct { type args struct {
device Device device Device
...@@ -79,11 +98,12 @@ func Test_pndImplementation_AddDevice(t *testing.T) { ...@@ -79,11 +98,12 @@ func Test_pndImplementation_AddDevice(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, description: tt.fields.desc,
Devices: tt.fields.devices, sbi: tt.fields.sbi,
devices: tt.fields.devices,
} }
if err := pnd.AddDevice(tt.args.device); (err != nil) != tt.wantErr { if err := pnd.AddDevice(&tt.args.device); (err != nil) != tt.wantErr {
t.Errorf("AddDevice() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("AddDevice() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
...@@ -94,11 +114,15 @@ func Test_pndImplementation_AddSbi(t *testing.T) { ...@@ -94,11 +114,15 @@ func Test_pndImplementation_AddSbi(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
}
type args struct {
sbi SouthboundInterface
} }
tests := []struct { tests := []struct {
name string name string
fields fields fields fields
args args
wantErr bool wantErr bool
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
...@@ -106,11 +130,11 @@ func Test_pndImplementation_AddSbi(t *testing.T) { ...@@ -106,11 +130,11 @@ func Test_pndImplementation_AddSbi(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.AddSbi(); (err != nil) != tt.wantErr { if err := pnd.AddSbi(tt.args.sbi); (err != nil) != tt.wantErr {
t.Errorf("AddSbi() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("AddSbi() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
...@@ -121,7 +145,7 @@ func Test_pndImplementation_Destroy(t *testing.T) { ...@@ -121,7 +145,7 @@ func Test_pndImplementation_Destroy(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
} }
tests := []struct { tests := []struct {
name string name string
...@@ -133,9 +157,9 @@ func Test_pndImplementation_Destroy(t *testing.T) { ...@@ -133,9 +157,9 @@ func Test_pndImplementation_Destroy(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.Destroy(); (err != nil) != tt.wantErr { if err := pnd.Destroy(); (err != nil) != tt.wantErr {
t.Errorf("Destroy() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("Destroy() error = %v, wantErr %v", err, tt.wantErr)
...@@ -148,7 +172,7 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) { ...@@ -148,7 +172,7 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
} }
type args struct { type args struct {
uuid uuid.UUID uuid uuid.UUID
...@@ -164,9 +188,9 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) { ...@@ -164,9 +188,9 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.RemoveDevice(tt.args.uuid); (err != nil) != tt.wantErr { if err := pnd.RemoveDevice(tt.args.uuid); (err != nil) != tt.wantErr {
t.Errorf("RemoveDevice() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("RemoveDevice() error = %v, wantErr %v", err, tt.wantErr)
...@@ -179,11 +203,15 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) { ...@@ -179,11 +203,15 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
}
type args struct {
sbi SouthboundInterface
} }
tests := []struct { tests := []struct {
name string name string
fields fields fields fields
args args
wantErr bool wantErr bool
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
...@@ -191,11 +219,11 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) { ...@@ -191,11 +219,11 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.RemoveSbi(); (err != nil) != tt.wantErr { if err := pnd.RemoveSbi(tt.args.sbi.SbiIdentifier()); (err != nil) != tt.wantErr {
t.Errorf("RemoveSbi() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("RemoveSbi() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
...@@ -206,7 +234,7 @@ func Test_pndImplementation_addDevice(t *testing.T) { ...@@ -206,7 +234,7 @@ func Test_pndImplementation_addDevice(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
} }
type args struct { type args struct {
device Device device Device
...@@ -222,11 +250,11 @@ func Test_pndImplementation_addDevice(t *testing.T) { ...@@ -222,11 +250,11 @@ func Test_pndImplementation_addDevice(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.addDevice(tt.args.device); (err != nil) != tt.wantErr { if err := pnd.addDevice(&tt.args.device); (err != nil) != tt.wantErr {
t.Errorf("addDevice() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("addDevice() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
...@@ -237,7 +265,7 @@ func Test_pndImplementation_removeDevice(t *testing.T) { ...@@ -237,7 +265,7 @@ func Test_pndImplementation_removeDevice(t *testing.T) {
type fields struct { type fields struct {
name string name string
sbi map[string]SouthboundInterface sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device devices map[uuid.UUID]*Device
} }
type args struct { type args struct {
uuid uuid.UUID uuid uuid.UUID
...@@ -253,9 +281,9 @@ func Test_pndImplementation_removeDevice(t *testing.T) { ...@@ -253,9 +281,9 @@ func Test_pndImplementation_removeDevice(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: tt.fields.name, name: tt.fields.name,
Sbi: tt.fields.sbi, sbi: tt.fields.sbi,
Devices: tt.fields.devices, devices: tt.fields.devices,
} }
if err := pnd.removeDevice(tt.args.uuid); (err != nil) != tt.wantErr { if err := pnd.removeDevice(tt.args.uuid); (err != nil) != tt.wantErr {
t.Errorf("removeDevice() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("removeDevice() error = %v, wantErr %v", err, tt.wantErr)
...@@ -265,15 +293,31 @@ func Test_pndImplementation_removeDevice(t *testing.T) { ...@@ -265,15 +293,31 @@ func Test_pndImplementation_removeDevice(t *testing.T) {
} }
func Test_removeSbi(t *testing.T) { func Test_removeSbi(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]*Device
}
type args struct {
uuid uuid.UUID
sbi SouthboundInterface
}
tests := []struct { tests := []struct {
name string name string
fields fields
args args
wantErr bool wantErr bool
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if err := removeSbi(); (err != nil) != tt.wantErr { pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.removeSbi(tt.args.sbi.SbiIdentifier()); (err != nil) != tt.wantErr {
t.Errorf("removeSbi() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("removeSbi() error = %v, wantErr %v", err, tt.wantErr)
} }
}) })
......
...@@ -16,7 +16,7 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) { ...@@ -16,7 +16,7 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{ oc := &OpenConfig{
Transport: tt.fields.transport, transport: tt.fields.transport,
} }
if got := oc.SbiIdentifier(); got != tt.want { if got := oc.SbiIdentifier(); got != tt.want {
t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want) t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want)
...@@ -42,7 +42,7 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) { ...@@ -42,7 +42,7 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{ oc := &OpenConfig{
Transport: tt.fields.transport, transport: tt.fields.transport,
} }
oc.OpenconfigInterfaces(tt.args.device) oc.OpenconfigInterfaces(tt.args.device)
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment