Skip to content

Commit

Permalink
Fix some report card issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ancientlore committed Feb 28, 2018
1 parent a3fa92b commit fda0de5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ctxmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Based on work from: https://github.com/gorilla/context
license that can be found in the LICENSE file.
*/

type sessionKey string

func TestContext(t *testing.T) {
assertEqual := func(val interface{}, exp interface{}) {
if val != exp {
Expand All @@ -32,7 +34,7 @@ func TestContext(t *testing.T) {
Set(r, ctx)
assertEqual(Get(r), ctx)

ctx2 := context.WithValue(ctx, "session", make(map[string]interface{}))
ctx2 := context.WithValue(ctx, sessionKey("session"), make(map[string]interface{}))
Set(r, ctx2)
assertEqual(Get(r), ctx2)

Expand Down Expand Up @@ -71,7 +73,7 @@ func parallelReader(r *http.Request, iterations int, wait, done chan struct{}) {

}

func parallelWriter(r *http.Request, value context.Context, iterations int, wait, done chan struct{}) {
func parallelWriter(value context.Context, r *http.Request, iterations int, wait, done chan struct{}) {
<-wait
for i := 0; i < iterations; i++ {
Set(r, value)
Expand Down Expand Up @@ -99,8 +101,8 @@ func benchmarkMutex(b *testing.B, numReaders, numWriters, iterations int) {

for i := 0; i < numWriters; i++ {
// to be fair in our tests and comparing against gorilla/context, let's set value
ctx := context.WithValue(context.Background(), "Foo", "1234")
go parallelWriter(reqs[i], ctx, iterations, wait, done)
ctx := context.WithValue(context.Background(), sessionKey("Foo"), "1234")
go parallelWriter(ctx, reqs[i], iterations, wait, done)
}

close(wait)
Expand Down

0 comments on commit fda0de5

Please sign in to comment.