Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
00de46e2
Commit
00de46e2
authored
Sep 27, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(test): fix a flaky pubsub test
parent
10d20732
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
tests/pubsub.go
tests/pubsub.go
+15
-1
No files found.
tests/pubsub.go
View file @
00de46e2
...
@@ -34,13 +34,20 @@ func (tp *TestSuite) TestBasicPubSub(t *testing.T) {
...
@@ -34,13 +34,20 @@ func (tp *TestSuite) TestBasicPubSub(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
done
:=
make
(
chan
struct
{})
go
func
()
{
go
func
()
{
defer
close
(
done
)
ticker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
ticker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
for
{
for
{
err
:=
apis
[
1
]
.
PubSub
()
.
Publish
(
ctx
,
"testch"
,
[]
byte
(
"hello world"
))
err
:=
apis
[
1
]
.
PubSub
()
.
Publish
(
ctx
,
"testch"
,
[]
byte
(
"hello world"
))
if
err
!=
nil
{
switch
err
{
case
nil
:
case
context
.
Canceled
:
return
default
:
t
.
Error
(
err
)
t
.
Error
(
err
)
cancel
()
cancel
()
return
return
...
@@ -53,6 +60,13 @@ func (tp *TestSuite) TestBasicPubSub(t *testing.T) {
...
@@ -53,6 +60,13 @@ func (tp *TestSuite) TestBasicPubSub(t *testing.T) {
}
}
}()
}()
// Wait for the sender to finish before we return.
// Otherwise, we can get random errors as publish fails.
defer
func
()
{
cancel
()
<-
done
}()
m
,
err
:=
sub
.
Next
(
ctx
)
m
,
err
:=
sub
.
Next
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment