Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xx network
comms
Commits
45ad1fa2
Commit
45ad1fa2
authored
Sep 22, 2020
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Fix nil issues in gossip tests
parent
c2304532
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
gossip/endpoint_test.go
+3
-3
3 additions, 3 deletions
gossip/endpoint_test.go
gossip/manager_test.go
+30
-6
30 additions, 6 deletions
gossip/manager_test.go
with
33 additions
and
9 deletions
gossip/endpoint_test.go
+
3
−
3
View file @
45ad1fa2
...
...
@@ -131,6 +131,6 @@ func TestManager_Endpoint_AddProtocol(t *testing.T) {
}
func
TestComms_Stream
(
t
*
testing
.
T
)
{
// TODO: Implement test once streaming is enabled
}
//
func TestComms_Stream(t *testing.T) {
//
// TODO: Implement test once streaming is enabled
//
}
This diff is collapsed.
Click to expand it.
gossip/manager_test.go
+
30
−
6
View file @
45ad1fa2
...
...
@@ -16,7 +16,11 @@ import (
// Basic test on manager creation
func
TestNewManager
(
t
*
testing
.
T
)
{
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
DefaultManagerFlags
())
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
DefaultManagerFlags
())
if
m
.
buffer
==
nil
||
m
.
protocols
==
nil
{
t
.
Error
(
"Failed to initialize all fields properly"
)
}
...
...
@@ -24,7 +28,11 @@ func TestNewManager(t *testing.T) {
// Happy path test for adding new gossip protocol
func
TestManager_NewGossip
(
t
*
testing
.
T
)
{
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
DefaultManagerFlags
())
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
DefaultManagerFlags
())
r
:=
func
(
msg
*
GossipMsg
)
error
{
return
nil
...
...
@@ -41,7 +49,11 @@ func TestManager_NewGossip(t *testing.T) {
// Happy path test for new gossip protocol with messages in buffer for that tag
func
TestManager_NewGossip_WithBuffer
(
t
*
testing
.
T
)
{
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
DefaultManagerFlags
())
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
DefaultManagerFlags
())
m
.
buffer
[
"test"
]
=
&
MessageRecord
{
Timestamp
:
time
.
Time
{},
Messages
:
[]
*
GossipMsg
{{
Tag
:
"testmsg"
}},
...
...
@@ -74,7 +86,11 @@ func TestManager_NewGossip_WithBuffer(t *testing.T) {
// Basic unit test for getting a protocol
func
TestManager_Get
(
t
*
testing
.
T
)
{
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
DefaultManagerFlags
())
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
DefaultManagerFlags
())
m
.
protocols
=
map
[
string
]
*
Protocol
{
"test"
:
{}}
_
,
ok
:=
m
.
Get
(
"test"
)
...
...
@@ -85,7 +101,11 @@ func TestManager_Get(t *testing.T) {
// Basic unit test for deleting a protocol
func
TestManager_Delete
(
t
*
testing
.
T
)
{
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
DefaultManagerFlags
())
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
DefaultManagerFlags
())
m
.
protocols
=
map
[
string
]
*
Protocol
{
"test"
:
{}}
m
.
Delete
(
"test"
)
...
...
@@ -99,7 +119,11 @@ func TestManager_BufferMonitor(t *testing.T) {
flags
:=
DefaultManagerFlags
()
flags
.
BufferExpirationTime
=
3
*
time
.
Second
flags
.
MonitorThreadFrequency
=
3
*
time
.
Second
m
:=
NewManager
(
&
connect
.
ProtoComms
{},
flags
)
pc
:=
&
connect
.
ProtoComms
{
Manager
:
connect
.
NewManagerTesting
(
t
),
}
m
:=
NewManager
(
pc
,
flags
)
m
.
buffer
[
"test"
]
=
&
MessageRecord
{
Timestamp
:
time
.
Now
(),
Messages
:
nil
,
...
...
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