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
45dfefc0
Commit
45dfefc0
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
added testcase for:
- NewGnmiTransport() - "fails wrong type" for pnd.AddDevice() and pnd.AddSBI()
parent
f24dd566
No related branches found
No related tags found
2 merge requests
!116
Resolve "Transport Tests"
,
!90
Develop
Pipeline
#66009
passed with warnings
4 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nucleus/gnmi_transport_test.go
+44
-0
44 additions, 0 deletions
nucleus/gnmi_transport_test.go
nucleus/principalNetworkDomain_test.go
+24
-3
24 additions, 3 deletions
nucleus/principalNetworkDomain_test.go
with
68 additions
and
3 deletions
nucleus/gnmi_transport_test.go
+
44
−
0
View file @
45dfefc0
...
...
@@ -37,6 +37,15 @@ func testSetupGnmi() {
Encoding
:
gpb
.
Encoding_PROTO
,
}
gnmiTransportOptions
=
&
GnmiTransportOptions
{
Username
:
"test"
,
Password
:
"test"
,
Addr
:
"localhost:13371"
,
SetNode
:
nil
,
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
Encoding
:
gpb
.
Encoding_PROTO
,
}
startGnmiTarget
=
make
(
chan
string
)
stopGnmiTarget
=
make
(
chan
bool
)
go
targetRunner
()
...
...
@@ -61,10 +70,45 @@ func mockTransport() Gnmi {
}
var
gnmiConfig
*
gnmi
.
Config
var
gnmiTransportOptions
*
GnmiTransportOptions
var
startGnmiTarget
chan
string
var
stopGnmiTarget
chan
bool
var
mockContext
=
mock
.
MatchedBy
(
func
(
ctx
context
.
Context
)
bool
{
return
true
})
func
TestNewGnmiTransport
(
t
*
testing
.
T
)
{
gnmiTransport
:=
mockTransport
()
type
args
struct
{
opts
*
GnmiTransportOptions
}
tests
:=
[]
struct
{
name
string
args
args
want
*
Gnmi
wantErr
bool
}{
{
name
:
"default"
,
args
:
args
{
opts
:
gnmiTransportOptions
,
},
want
:
&
gnmiTransport
,
wantErr
:
false
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
NewGnmiTransport
(
tt
.
args
.
opts
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"NewGnmiTransport() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"NewGnmiTransport() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
func
TestGnmi_Capabilities
(
t
*
testing
.
T
)
{
transport
:=
mockTransport
()
capabilityResponse
:=
&
gpb
.
CapabilityResponse
{
...
...
This diff is collapsed.
Click to expand it.
nucleus/principalNetworkDomain_test.go
+
24
−
3
View file @
45dfefc0
...
...
@@ -169,7 +169,7 @@ func Test_destroy(t *testing.T) {
func
Test_pndImplementation_AddDevice
(
t
*
testing
.
T
)
{
type
args
struct
{
device
*
Device
device
interface
{}
}
tests
:=
[]
struct
{
name
string
...
...
@@ -183,6 +183,13 @@ func Test_pndImplementation_AddDevice(t *testing.T) {
}},
wantErr
:
false
,
},
{
name
:
"fails wrong type"
,
args
:
args
{
device
:
&
pndImplementation
{
id
:
did
,
}},
wantErr
:
true
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -204,7 +211,7 @@ func Test_pndImplementation_AddDevice(t *testing.T) {
func
Test_pndImplementation_AddSbi
(
t
*
testing
.
T
)
{
type
args
struct
{
sbi
SouthboundI
nterface
sbi
i
nterface
{}
}
tests
:=
[]
struct
{
name
string
...
...
@@ -220,6 +227,15 @@ func Test_pndImplementation_AddSbi(t *testing.T) {
},
wantErr
:
false
,
},
{
name
:
"fails wrong type"
,
args
:
args
{
sbi
:
&
pndImplementation
{
id
:
defaultSbiId
,
},
},
wantErr
:
true
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -370,7 +386,12 @@ func Test_pndImplementation_MarshalDevice(t *testing.T) {
want
string
wantErr
bool
}{
{
name
:
"default"
,
args
:
args
{
did
},
want
:
"{
\n\t\"
Acl
\"
: null,
\n\t\"
Bgp
\"
: null,
\n\t\"
Components
\"
: null,
\n\t\"
Interfaces
\"
: null,
\n\t\"
LocalRoutes
\"
: null,
\n\t\"
Messages
\"
: null,
\n\t\"
NetworkInstances
\"
: null,
\n\t\"
RoutingPolicy
\"
: null,
\n\t\"
System
\"
: null
\n
}"
,
wantErr
:
false
},
{
name
:
"default"
,
args
:
args
{
did
},
want
:
"{
\n\t\"
Acl
\"
: null,
\n\t\"
Bgp
\"
: null,
\n\t\"
Components
\"
: null,
\n\t\"
Interfaces
\"
: null,
\n\t\"
LocalRoutes
\"
: null,
\n\t\"
Messages
\"
: null,
\n\t\"
NetworkInstances
\"
: null,
\n\t\"
RoutingPolicy
\"
: null,
\n\t\"
System
\"
: null
\n
}"
,
wantErr
:
false
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
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