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
Łukasz Nowak
caddy
Commits
6e9439d2
Commit
6e9439d2
authored
Aug 02, 2016
by
Nimi Wariboko Jr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proxy: Fix data race in test.
parent
f4cdf537
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
caddyhttp/proxy/proxy_test.go
caddyhttp/proxy/proxy_test.go
+4
-3
No files found.
caddyhttp/proxy/proxy_test.go
View file @
6e9439d2
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
"path/filepath"
"path/filepath"
"runtime"
"runtime"
"strings"
"strings"
"sync/atomic"
"testing"
"testing"
"time"
"time"
...
@@ -102,8 +103,8 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) {
...
@@ -102,8 +103,8 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) {
func
TestWebSocketReverseProxyServeHTTPHandler
(
t
*
testing
.
T
)
{
func
TestWebSocketReverseProxyServeHTTPHandler
(
t
*
testing
.
T
)
{
// No-op websocket backend simply allows the WS connection to be
// No-op websocket backend simply allows the WS connection to be
// accepted then it will be immediately closed. Perfect for testing.
// accepted then it will be immediately closed. Perfect for testing.
var
connCount
int
var
connCount
int
32
wsNop
:=
httptest
.
NewServer
(
websocket
.
Handler
(
func
(
ws
*
websocket
.
Conn
)
{
connCount
++
}))
wsNop
:=
httptest
.
NewServer
(
websocket
.
Handler
(
func
(
ws
*
websocket
.
Conn
)
{
atomic
.
AddInt32
(
&
connCount
,
1
)
}))
defer
wsNop
.
Close
()
defer
wsNop
.
Close
()
// Get proxy to use for the test
// Get proxy to use for the test
...
@@ -136,7 +137,7 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
...
@@ -136,7 +137,7 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
if
!
bytes
.
Equal
(
actual
,
expected
)
{
if
!
bytes
.
Equal
(
actual
,
expected
)
{
t
.
Errorf
(
"Expected backend to accept response:
\n
'%s'
\n
Actually got:
\n
'%s'"
,
expected
,
actual
)
t
.
Errorf
(
"Expected backend to accept response:
\n
'%s'
\n
Actually got:
\n
'%s'"
,
expected
,
actual
)
}
}
if
connCount
!=
1
{
if
atomic
.
LoadInt32
(
&
connCount
)
!=
1
{
t
.
Errorf
(
"Expected 1 websocket connection, got %d"
,
connCount
)
t
.
Errorf
(
"Expected 1 websocket connection, got %d"
,
connCount
)
}
}
}
}
...
...
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