Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
b65ddbc7
Commit
b65ddbc7
authored
Dec 10, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
a44d59f1
aba0ae35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
middleware/markdown/watcher_test.go
middleware/markdown/watcher_test.go
+13
-5
No files found.
middleware/markdown/watcher_test.go
View file @
b65ddbc7
...
@@ -13,14 +13,14 @@ func TestWatcher(t *testing.T) {
...
@@ -13,14 +13,14 @@ func TestWatcher(t *testing.T) {
interval
:=
time
.
Millisecond
*
100
interval
:=
time
.
Millisecond
*
100
i
:=
0
i
:=
0
out
:=
""
out
:=
""
syncChan
:=
make
(
chan
struct
{})
stopChan
:=
TickerFunc
(
interval
,
func
()
{
stopChan
:=
TickerFunc
(
interval
,
func
()
{
i
++
i
++
out
+=
fmt
.
Sprint
(
i
)
out
+=
fmt
.
Sprint
(
i
)
syncChan
<-
struct
{}{}
})
})
// wait little more because of concurrency
sleepInSync
(
8
,
syncChan
,
stopChan
)
time
.
Sleep
(
interval
*
9
)
if
out
!=
expected
{
stopChan
<-
struct
{}{}
if
!
strings
.
HasPrefix
(
out
,
expected
)
{
t
.
Fatalf
(
"Expected to have prefix %v, found %v"
,
expected
,
out
)
t
.
Fatalf
(
"Expected to have prefix %v, found %v"
,
expected
,
out
)
}
}
out
=
""
out
=
""
...
@@ -31,8 +31,9 @@ func TestWatcher(t *testing.T) {
...
@@ -31,8 +31,9 @@ func TestWatcher(t *testing.T) {
mu
.
Lock
()
mu
.
Lock
()
out
+=
fmt
.
Sprint
(
i
)
out
+=
fmt
.
Sprint
(
i
)
mu
.
Unlock
()
mu
.
Unlock
()
syncChan
<-
struct
{}{}
})
})
time
.
Sleep
(
interval
*
10
)
sleepInSync
(
9
,
syncChan
,
stopChan
)
mu
.
Lock
()
mu
.
Lock
()
res
:=
out
res
:=
out
mu
.
Unlock
()
mu
.
Unlock
()
...
@@ -40,3 +41,10 @@ func TestWatcher(t *testing.T) {
...
@@ -40,3 +41,10 @@ func TestWatcher(t *testing.T) {
t
.
Fatalf
(
"expected (%v) must be a proper prefix of out(%v)."
,
expected
,
out
)
t
.
Fatalf
(
"expected (%v) must be a proper prefix of out(%v)."
,
expected
,
out
)
}
}
}
}
func
sleepInSync
(
times
int
,
syncChan
chan
struct
{},
stopChan
chan
struct
{})
{
for
i
:=
0
;
i
<
times
;
i
++
{
<-
syncChan
}
stopChan
<-
struct
{}{}
}
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