-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 [Bug]: cache middleware: runtime error: index out of range [0] with…
… length 0 (#3075) Resolves #3072 Signed-off-by: brunodmartins <[email protected]>
- Loading branch information
1 parent
a57b3c0
commit f413bfe
Showing
5 changed files
with
190 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cache | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/gofiber/utils/v2" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_manager_get(t *testing.T) { | ||
t.Parallel() | ||
cacheManager := newManager(nil) | ||
t.Run("Item not found in cache", func(t *testing.T) { | ||
t.Parallel() | ||
assert.Nil(t, cacheManager.get(utils.UUID())) | ||
}) | ||
t.Run("Item found in cache", func(t *testing.T) { | ||
t.Parallel() | ||
id := utils.UUID() | ||
cacheItem := cacheManager.acquire() | ||
cacheItem.body = []byte("test-body") | ||
cacheManager.set(id, cacheItem, 10*time.Second) | ||
assert.NotNil(t, cacheManager.get(id)) | ||
}) | ||
} |
f413bfe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.50
.Benchmark_Ctx_SendString_B
17.65
ns/op 0 B/op 0 allocs/op7.748
ns/op 0 B/op 0 allocs/op2.28
Benchmark_Ctx_SendString_B - ns/op
17.65
ns/op7.748
ns/op2.28
Benchmark_Utils_GetOffer/1_parameter
214.5
ns/op 0 B/op 0 allocs/op136.1
ns/op 0 B/op 0 allocs/op1.58
Benchmark_Utils_GetOffer/1_parameter - ns/op
214.5
ns/op136.1
ns/op1.58
Benchmark_Utils_getGroupPath - allocs/op
4
allocs/op2
allocs/op2
Benchmark_Middleware_BasicAuth - B/op
80
B/op48
B/op1.67
Benchmark_Middleware_BasicAuth - allocs/op
5
allocs/op3
allocs/op1.67
Benchmark_Middleware_BasicAuth_Upper - B/op
80
B/op48
B/op1.67
Benchmark_Middleware_BasicAuth_Upper - allocs/op
5
allocs/op3
allocs/op1.67
Benchmark_CORS_NewHandler - B/op
16
B/op0
B/op+∞
Benchmark_CORS_NewHandler - allocs/op
1
allocs/op0
allocs/op+∞
Benchmark_CORS_NewHandlerSingleOrigin - B/op
16
B/op0
B/op+∞
Benchmark_CORS_NewHandlerSingleOrigin - allocs/op
1
allocs/op0
allocs/op+∞
Benchmark_CORS_NewHandlerPreflight
1158
ns/op 104 B/op 5 allocs/op759.2
ns/op 0 B/op 0 allocs/op1.53
Benchmark_CORS_NewHandlerPreflight - ns/op
1158
ns/op759.2
ns/op1.53
Benchmark_CORS_NewHandlerPreflight - B/op
104
B/op0
B/op+∞
Benchmark_CORS_NewHandlerPreflight - allocs/op
5
allocs/op0
allocs/op+∞
Benchmark_CORS_NewHandlerPreflightSingleOrigin
1155
ns/op 104 B/op 5 allocs/op757.5
ns/op 0 B/op 0 allocs/op1.52
Benchmark_CORS_NewHandlerPreflightSingleOrigin - ns/op
1155
ns/op757.5
ns/op1.52
Benchmark_CORS_NewHandlerPreflightSingleOrigin - B/op
104
B/op0
B/op+∞
Benchmark_CORS_NewHandlerPreflightSingleOrigin - allocs/op
5
allocs/op0
allocs/op+∞
Benchmark_CORS_NewHandlerPreflightWildcard
1063
ns/op 104 B/op 5 allocs/op691
ns/op 0 B/op 0 allocs/op1.54
Benchmark_CORS_NewHandlerPreflightWildcard - ns/op
1063
ns/op691
ns/op1.54
Benchmark_CORS_NewHandlerPreflightWildcard - B/op
104
B/op0
B/op+∞
Benchmark_CORS_NewHandlerPreflightWildcard - allocs/op
5
allocs/op0
allocs/op+∞
Benchmark_Middleware_CSRF_Check - allocs/op
11
allocs/op7
allocs/op1.57
Benchmark_Middleware_CSRF_GenerateToken - B/op
515
B/op326
B/op1.58
Benchmark_Middleware_CSRF_GenerateToken - allocs/op
10
allocs/op6
allocs/op1.67
This comment was automatically generated by workflow using github-action-benchmark.