Skip to content
Snippets Groups Projects
Commit c12cd471 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

test skeleton

parent 31dbfa67
No related branches found
No related tags found
3 merge requests!92Resolve "Increase test coverage",!91"Overhaul Architecture",!90Develop
This commit is part of merge request !91. Comments created here will be created in the context of that merge request.
......@@ -2,6 +2,7 @@ package nucleus
// ClientConfig contains SBI ciena
// configuration parameters
// Deprecated in favor of spf viper
type ClientConfig struct {
Identifier string `toml:"identifier"`
Endpoint string `toml:"endpoint"`
......
package nucleus
import (
"github.com/openconfig/ygot/ygot"
log "github.com/sirupsen/logrus"
"testing"
)
func TestDevice_Add(t *testing.T) {
type fields struct {
Device ygot.GoStruct
SBI SouthboundInterface
Config DeviceConfig
Transport Transport
}
type args struct {
resp interface{}
}
tests := []struct {
name string
fields fields
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := Device{
Device: tt.fields.Device,
SBI: tt.fields.SBI,
Config: tt.fields.Config,
Transport: tt.fields.Transport,
}
log.Debug(d.SBI.SbiIdentifier())
})
}
}
\ No newline at end of file
package nucleus
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"context"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/gnmi/proto/gnmi_ext"
"reflect"
"testing"
)
func TestGetWithRequest(t *testing.T) {
type args struct {
ctx context.Context
req *gpb.GetRequest
}
tests := []struct {
name string
args args
want interface{}
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetWithRequest(tt.args.ctx, tt.args.req)
if (err != nil) != tt.wantErr {
t.Errorf("GetWithRequest() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetWithRequest() got = %v, want %v", got, tt.want)
}
})
}
}
func TestGnmi_Capabilities(t *testing.T) {
type args struct {
ctx context.Context
}
tests := []struct {
name string
g Gnmi
args args
want interface{}
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.g.Capabilities(tt.args.ctx)
if (err != nil) != tt.wantErr {
t.Errorf("Capabilities() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Capabilities() got = %v, want %v", got, tt.want)
}
})
}
}
func TestGnmi_Close(t *testing.T) {
tests := []struct {
name string
g Gnmi
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.g.Close(); (err != nil) != tt.wantErr {
t.Errorf("Close() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestGnmi_Get(t *testing.T) {
type args struct {
ctx context.Context
paths [][]string
origin string
}
tests := []struct {
name string
g Gnmi
args args
want interface{}
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.g.Get(tt.args.ctx, tt.args.paths, tt.args.origin)
if (err != nil) != tt.wantErr {
t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Get() got = %v, want %v", got, tt.want)
}
})
}
}
func TestGnmi_GetConfig(t *testing.T) {
tests := []struct {
name string
g Gnmi
want interface{}
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.g.GetConfig(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetConfig() = %v, want %v", got, tt.want)
}
})
}
}
func TestGnmi_Set(t *testing.T) {
type args struct {
ctx context.Context
setOps []*gnmi.Operation
exts []*gnmi_ext.Extension
}
tests := []struct {
name string
g Gnmi
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.g.Set(tt.args.ctx, tt.args.setOps, tt.args.exts...); (err != nil) != tt.wantErr {
t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestGnmi_SetConfig(t *testing.T) {
type args struct {
in0 interface{}
}
tests := []struct {
name string
g Gnmi
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.g.SetConfig(tt.args.in0); (err != nil) != tt.wantErr {
t.Errorf("SetConfig() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestGnmi_Subscribe(t *testing.T) {
type args struct {
ctx context.Context
subscribeOptions *gnmi.SubscribeOptions
respChan chan<- *gpb.SubscribeResponse
}
tests := []struct {
name string
g Gnmi
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.g.Subscribe(tt.args.ctx, tt.args.subscribeOptions, tt.args.respChan); (err != nil) != tt.wantErr {
t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
package nucleus
import (
"github.com/google/uuid"
"reflect"
"testing"
)
func TestNewPND(t *testing.T) {
type args struct {
name string
sbi SouthboundInterface
}
tests := []struct {
name string
args args
want PrincipalNetworkDomain
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewPND(tt.args.name, tt.args.sbi); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewPND() = %v, want %v", got, tt.want)
}
})
}
}
func Test_addSbi(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := addSbi(); (err != nil) != tt.wantErr {
t.Errorf("addSbi() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_destroy(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := destroy(); (err != nil) != tt.wantErr {
t.Errorf("destroy() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_AddDevice(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
type args struct {
device Device
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.AddDevice(tt.args.device); (err != nil) != tt.wantErr {
t.Errorf("AddDevice() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_AddSbi(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
tests := []struct {
name string
fields fields
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.AddSbi(); (err != nil) != tt.wantErr {
t.Errorf("AddSbi() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_Destroy(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
tests := []struct {
name string
fields fields
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.Destroy(); (err != nil) != tt.wantErr {
t.Errorf("Destroy() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_RemoveDevice(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
type args struct {
uuid uuid.UUID
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.RemoveDevice(tt.args.uuid); (err != nil) != tt.wantErr {
t.Errorf("RemoveDevice() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_RemoveSbi(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
tests := []struct {
name string
fields fields
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.RemoveSbi(); (err != nil) != tt.wantErr {
t.Errorf("RemoveSbi() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_addDevice(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
type args struct {
device Device
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.addDevice(tt.args.device); (err != nil) != tt.wantErr {
t.Errorf("addDevice() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_pndImplementation_removeDevice(t *testing.T) {
type fields struct {
name string
sbi map[string]SouthboundInterface
devices map[uuid.UUID]Device
}
type args struct {
uuid uuid.UUID
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pnd := &pndImplementation{
name: tt.fields.name,
sbi: tt.fields.sbi,
devices: tt.fields.devices,
}
if err := pnd.removeDevice(tt.args.uuid); (err != nil) != tt.wantErr {
t.Errorf("removeDevice() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_removeSbi(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := removeSbi(); (err != nil) != tt.wantErr {
t.Errorf("removeSbi() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
package nucleus
import (
"context"
"reflect"
"testing"
)
func TestRestconf_GetConfig(t *testing.T) {
tests := []struct {
name string
want interface{}
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rc := &Restconf{}
if got := rc.GetConfig(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetConfig() = %v, want %v", got, tt.want)
}
})
}
}
func TestRestconf_SetConfig(t *testing.T) {
type args struct {
in0 interface{}
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rc := &Restconf{}
if err := rc.SetConfig(tt.args.in0); (err != nil) != tt.wantErr {
t.Errorf("SetConfig() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestRestconf_Subscribe(t *testing.T) {
type args struct {
ctx context.Context
params []string
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rc := &Restconf{}
if err := rc.Subscribe(tt.args.ctx, tt.args.params...); (err != nil) != tt.wantErr {
t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
......@@ -3,7 +3,7 @@ package nucleus
// SouthboundInterface provides an
// interface for SBI implementations
type SouthboundInterface interface {
GetSBIString() string
SbiIdentifier() string
}
type Tapi struct {
......@@ -13,7 +13,7 @@ type OpenConfig struct {
transport Transport
}
func (oc *OpenConfig) GetSBIString() string {
func (oc *OpenConfig) SbiIdentifier() string {
return "openconfig"
}
......
package nucleus
import "testing"
func TestOpenConfig_SbiIdentifier(t *testing.T) {
type fields struct {
transport Transport
}
tests := []struct {
name string
fields fields
want string
}{
{name: "default", want: "openconfig"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{
transport: tt.fields.transport,
}
if got := oc.SbiIdentifier(); got != tt.want {
t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want)
}
})
}
}
func TestOpenConfig_OpenconfigInterfaces(t *testing.T) {
type fields struct {
transport Transport
}
type args struct {
device Device
}
tests := []struct {
name string
fields fields
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{
transport: tt.fields.transport,
}
oc.OpenconfigInterfaces(tt.args.device)
})
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment