Skip to content

Commit

Permalink
test: context test cases for custom key
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanialr committed Sep 11, 2024
1 parent 6bab7c0 commit 9799af9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ func TestContext(t *testing.T) {
assert.Equal(t, httpCtx.Value("Hello").(string), "world")
assert.Equal(t, httpCtx.Value("Hi").(string), "Goravel")
}

func TestContextWithCustomKeyType(t *testing.T) {
type customKeyType struct{}
var customKey customKeyType
var customKeyTwo customKeyType

httpCtx := Background()
httpCtx.WithValue(customKey, "hello")
httpCtx.WithValue(customKeyTwo, "world")

assert.Equal(t, httpCtx.Value(customKey), "hello")
assert.Equal(t, httpCtx.Value(customKeyTwo), "world")
}

0 comments on commit 9799af9

Please sign in to comment.