Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencegripper committed Oct 23, 2018
1 parent 8c96954 commit ee806af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
language: go
go:
- 1.7
- 1.8
- 1.9
- "1.10"
- "1.11"
- tip

script:
- go test -v -race -coverprofile=coverage.txt -covermode=atomic ./
- go test -v -race -parallel 5 -coverprofile=coverage.txt -covermode=atomic ./
- go test github.com/fortytw2/leaktest -run ^TestEmptyLeak$

before_install:
Expand Down
19 changes: 13 additions & 6 deletions leaktest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,28 @@ func TestCheck(t *testing.T) {
name: "HTTP Client with KeepAlive Disabled.",
expectLeak: false,
f: func() {
http.DefaultTransport.(*http.Transport).DisableKeepAlives = true
http.Get("http://localhost:8091")
tr := &http.Transport{
DisableKeepAlives: true,
}
client := &http.Client{Transport: tr}
_, err := client.Get("http://localhost:8091")
if err != nil {
t.Error(err)
}
},
},
{
name: "HTTP Client with KeepAlive Enabled.",
expectLeak: true,
f: func() {
http.DefaultTransport.(*http.Transport).DisableKeepAlives = false

_, err := http.Get("http://localhost:8091")
tr := &http.Transport{
DisableKeepAlives: false,
}
client := &http.Client{Transport: tr}
_, err := client.Get("http://localhost:8091")
if err != nil {
t.Error(err)
}

},
},
}
Expand Down

0 comments on commit ee806af

Please sign in to comment.