good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
open
bor
Commits
8e2bf42c
Commit
8e2bf42c
authored
9 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
event/filter: fix data race in the test
parent
e3f36d97
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
event/filter/filter_test.go
+17
-12
17 additions, 12 deletions
event/filter/filter_test.go
with
17 additions
and
12 deletions
event/filter/filter_test.go
+
17
−
12
View file @
8e2bf42c
...
...
@@ -21,35 +21,40 @@ import (
"time"
)
// Simple test to check if baseline matching/mismatching filtering works.
func
TestFilters
(
t
*
testing
.
T
)
{
var
success
bool
var
failure
bool
fm
:=
New
()
fm
.
Start
()
// Register two filters to catch posted data
first
:=
make
(
chan
struct
{})
fm
.
Install
(
Generic
{
Str1
:
"hello"
,
Fn
:
func
(
data
interface
{})
{
success
=
data
.
(
bool
)
first
<-
struct
{}{}
},
})
second
:=
make
(
chan
struct
{})
fm
.
Install
(
Generic
{
Str1
:
"hello1"
,
Str2
:
"hello"
,
Fn
:
func
(
data
interface
{})
{
failure
=
true
second
<-
struct
{}{}
},
})
// Post an event that should only match the first filter
fm
.
Notify
(
Generic
{
Str1
:
"hello"
},
true
)
fm
.
Stop
()
time
.
Sleep
(
10
*
time
.
Millisecond
)
// yield to the notifier
if
!
success
{
t
.
Error
(
"expected 'hello' to be posted"
)
// Ensure only the mathcing filters fire
select
{
case
<-
first
:
case
<-
time
.
After
(
100
*
time
.
Millisecond
)
:
t
.
Error
(
"matching filter timed out"
)
}
if
failure
{
t
.
Error
(
"hello1 was triggered"
)
select
{
case
<-
second
:
t
.
Error
(
"mismatching filter fired"
)
case
<-
time
.
After
(
100
*
time
.
Millisecond
)
:
}
}
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