Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
de669a68
Commit
de669a68
authored
2 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Update test cases for networkElement
parent
6153780c
No related branches found
No related tags found
1 merge request
!401
Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
controller/nucleus/networkElement_test.go
+13
-19
13 additions, 19 deletions
controller/nucleus/networkElement_test.go
with
13 additions
and
19 deletions
controller/nucleus/networkElement_test.go
+
13
−
19
View file @
de669a68
...
@@ -5,20 +5,18 @@ import (
...
@@ -5,20 +5,18 @@ import (
"testing"
"testing"
"code.fbi.h-da.de/danet/gosdn/controller/conflict"
"code.fbi.h-da.de/danet/gosdn/controller/conflict"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/
southbound
"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/
plugin
"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport"
"code.fbi.h-da.de/danet/gosdn/controller/mocks"
tpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
tpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
"code.fbi.h-da.de/danet/gosdn/models/generated/openconfig"
"github.com/google/uuid"
"github.com/google/uuid"
"github.com/openconfig/ygot/ygot"
)
)
func
TestNetworkElement_Id
(
t
*
testing
.
T
)
{
func
TestNetworkElement_Id
(
t
*
testing
.
T
)
{
type
fields
struct
{
type
fields
struct
{
Model
ygot
.
ValidatedGoStruct
Plugin
plugin
.
Plugin
SBI
southbound
.
SouthboundInterface
Transport
transport
.
Transport
Transport
transport
.
Transport
UUID
uuid
.
UUID
UUID
uuid
.
UUID
Name
string
Name
string
...
@@ -39,8 +37,7 @@ func TestNetworkElement_Id(t *testing.T) {
...
@@ -39,8 +37,7 @@ func TestNetworkElement_Id(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
:=
&
CommonNetworkElement
{
d
:=
&
CommonNetworkElement
{
Plugin
:
tt
.
fields
.
Model
,
Plugin
:
tt
.
fields
.
Plugin
,
sbi
:
tt
.
fields
.
SBI
,
transport
:
tt
.
fields
.
Transport
,
transport
:
tt
.
fields
.
Transport
,
UUID
:
tt
.
fields
.
UUID
,
UUID
:
tt
.
fields
.
UUID
,
name
:
tt
.
fields
.
Name
,
name
:
tt
.
fields
.
Name
,
...
@@ -53,11 +50,11 @@ func TestNetworkElement_Id(t *testing.T) {
...
@@ -53,11 +50,11 @@ func TestNetworkElement_Id(t *testing.T) {
}
}
func
TestNewNetworkElement
(
t
*
testing
.
T
)
{
func
TestNewNetworkElement
(
t
*
testing
.
T
)
{
sbi
:=
&
OpenConfig
{}
mockPlugin
:=
mockPlugin
(
t
)
type
args
struct
{
type
args
struct
{
sbi
southbound
.
SouthboundInterface
plugin
plugin
.
Plugin
opts
*
tpb
.
TransportOption
opts
*
tpb
.
TransportOption
name
string
name
string
}
}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
...
@@ -67,7 +64,7 @@ func TestNewNetworkElement(t *testing.T) {
...
@@ -67,7 +64,7 @@ func TestNewNetworkElement(t *testing.T) {
{
{
name
:
"default"
,
name
:
"default"
,
args
:
args
{
args
:
args
{
sbi
:
sbi
,
plugin
:
mockPlugin
,
opts
:
&
tpb
.
TransportOption
{
opts
:
&
tpb
.
TransportOption
{
Address
:
"test:///"
,
Address
:
"test:///"
,
Username
:
"test"
,
Username
:
"test"
,
...
@@ -87,7 +84,7 @@ func TestNewNetworkElement(t *testing.T) {
...
@@ -87,7 +84,7 @@ func TestNewNetworkElement(t *testing.T) {
{
{
name
:
"invalid options"
,
name
:
"invalid options"
,
args
:
args
{
args
:
args
{
sbi
:
sbi
,
plugin
:
mockPlugin
,
opts
:
&
tpb
.
TransportOption
{
opts
:
&
tpb
.
TransportOption
{
Address
:
"test:///"
,
Address
:
"test:///"
,
Username
:
"test"
,
Username
:
"test"
,
...
@@ -102,21 +99,18 @@ func TestNewNetworkElement(t *testing.T) {
...
@@ -102,21 +99,18 @@ func TestNewNetworkElement(t *testing.T) {
tt
:=
tt
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Parallel
()
t
.
Parallel
()
resp
,
err
:=
NewNetworkElement
(
tt
.
args
.
name
,
uuid
.
Nil
,
tt
.
args
.
opts
,
tt
.
args
.
sbi
,
conflict
.
Metadata
{})
resp
,
err
:=
NewNetworkElement
(
tt
.
args
.
name
,
uuid
.
Nil
,
tt
.
args
.
opts
,
tt
.
args
.
plugin
,
conflict
.
Metadata
{})
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"NewNetworkElement() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
t
.
Errorf
(
"NewNetworkElement() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
return
}
}
if
resp
!=
nil
{
if
resp
!=
nil
{
if
reflect
.
TypeOf
(
resp
.
Get
Model
())
!=
reflect
.
TypeOf
(
&
openconfig
.
Device
{})
{
if
reflect
.
TypeOf
(
resp
.
Get
Plugin
())
!=
reflect
.
TypeOf
(
&
mocks
.
Plugin
{})
{
t
.
Error
(
"NewNetworkElement() returned invalid
GoStruct
"
)
t
.
Error
(
"NewNetworkElement() returned invalid
plugin
"
)
}
}
if
reflect
.
TypeOf
(
resp
.
Transport
())
!=
reflect
.
TypeOf
(
&
Gnmi
{})
{
if
reflect
.
TypeOf
(
resp
.
Transport
())
!=
reflect
.
TypeOf
(
&
Gnmi
{})
{
t
.
Error
(
"NewNetworkElement() returned invalid transport"
)
t
.
Error
(
"NewNetworkElement() returned invalid transport"
)
}
}
if
reflect
.
TypeOf
(
resp
.
SBI
())
!=
reflect
.
TypeOf
(
&
OpenConfig
{})
{
t
.
Error
(
"NewNetworkElement() returned invalid GoStruct"
)
}
if
resp
.
Name
()
!=
"MyNetworkElement"
{
if
resp
.
Name
()
!=
"MyNetworkElement"
{
t
.
Error
(
"NewNetworkElement() returned wrong name"
)
t
.
Error
(
"NewNetworkElement() returned wrong name"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment