chore: Enabling shuffling, cleanup and consistency across tests (#2931)

* Make Test/Benchmark names consistent. Add Makefile for GoFiber developers

* Cleanup README and Makefile

* Update statement
pull/2935/head
Juan Calderon-Perez 2024-03-24 15:54:56 -04:00 committed by GitHub
parent 3209052305
commit 95c181469d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 187 additions and 114 deletions

48
.github/README.md vendored
View File

@ -26,18 +26,20 @@
</a>
</p>
<p align="center">
<b>Fiber</b> is an <a href="https://github.com/expressjs/express">Express</a> inspired <b>web framework</b> built on top of <a href="https://github.com/valyala/fasthttp">Fasthttp</a>, the <b>fastest</b> HTTP engine for <a href="https://go.dev/doc/">Go</a>. Designed to <b>ease</b> things up for <b>fast</b> development with <b>zero memory allocation</b> and <b>performance</b> in mind.
<em><b>Fiber</b> is an <a href="https://github.com/expressjs/express">Express</a> inspired <b>web framework</b> built on top of <a href="https://github.com/valyala/fasthttp">Fasthttp</a>, the <b>fastest</b> HTTP engine for <a href="https://go.dev/doc/">Go</a>. Designed to <b>ease</b> things up for <b>fast</b> development with <b>zero memory allocation</b> and <b>performance</b> in mind.</em>
</p>
---
## ⚠️ **Attention**
Fiber v3 is currently in beta and under active development. While it offers exciting new features, please note that it may not be stable for production use. We recommend sticking to the latest stable release (v2.x) for mission-critical applications. If you choose to use v3, be prepared for potential bugs and breaking changes. Always check the official documentation and release notes for updates and proceed with caution. Happy coding! 🚀
---
## ⚙️ Installation
Before you begin, ensure you have Go installed on your system. Fiber requires **Go version `1.21` or higher** to run. You can check your current Go version by running `go version` in your terminal. If you need to install or upgrade Go, visit the [official Go download page](https://go.dev/dl/).
Once you have verified your Go installation, you can start setting up your project. Create a new directory for your project and navigate into it. Then, initialize your project with Go modules by executing the following command in your terminal:
Fiber requires **Go version `1.21` or higher** to run. If you need to install or upgrade Go, visit the [official Go download page](https://go.dev/dl/). To start setting up your project. Create a new directory for your project and navigate into it. Then, initialize your project with Go modules by executing the following command in your terminal:
```bash
go mod init github.com/your/repo
@ -60,7 +62,11 @@ Getting started with Fiber is easy. Here's a basic example to create a simple we
```go
package main
import "github.com/gofiber/fiber/v3"
import (
"log"
"github.com/gofiber/fiber/v3"
)
func main() {
// Initialize a new Fiber app
@ -73,7 +79,7 @@ func main() {
})
// Start the server on port 3000
app.Listen(":3000")
log.Fatal(app.Listen(":3000"))
}
```
@ -186,7 +192,6 @@ func main() {
// ]
// }
log.Fatal(app.Listen(":3000"))
}
@ -262,6 +267,8 @@ Checkout our [Template](https://github.com/gofiber/template) package that suppor
package main
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/template/pug"
)
@ -437,6 +444,8 @@ func main() {
```go
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/websocket"
)
@ -471,6 +480,8 @@ func main() {
```go
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/valyala/fasthttp"
)
@ -512,6 +523,8 @@ func main() {
```go
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/recover"
)
@ -537,6 +550,8 @@ func main() {
```go
import (
"log"
"github.com/gofiber/fiber/v3"
)
@ -611,6 +626,21 @@ If you want to say **Thank You** and/or support the active development of `Fiber
3. Write a review or tutorial on [Medium](https://medium.com/), [Dev.to](https://dev.to/) or personal blog.
4. Support the project by donating a [cup of coffee](https://buymeacoff.ee/fenny).
## 🖥️ Development
To ensure your contributions are ready for a Pull Request, please use the following `Makefile` commands. These tools help maintain code quality, consistency.
* **make help**: Display available commands.
* **make audit**: Conduct quality checks.
* **make benchmark**: Benchmark code performance.
* **make coverage**: Generate test coverage report.
* **make format**: Automatically format code.
* **make lint**: Run lint checks.
* **make test**: Execute all tests.
* **make tidy**: Tidy dependencies.
Run these commands to ensure your code adheres to project standards and best practices.
## ☕ Supporters
Fiber is an open source project that runs on donations to pay the bills e.g. our domain name, gitbook, netlify and serverless hosting. If you want to support Fiber, you can ☕ [**buy a coffee here**](https://buymeacoff.ee/fenny).
@ -636,7 +666,7 @@ Fiber is an open source project that runs on donations to pay the bills e.g. our
| ![](https://avatars.githubusercontent.com/u/31022056?s=25) | [@marvinjwendt](https://github.com/marvinjwendt) | ☕ x 1 |
| ![](https://avatars.githubusercontent.com/u/31921460?s=25) | [@toishy](https://github.com/toishy) | ☕ x 1 |
## 💻 Code Contributors
## 💻 Code Contributors
<img src="https://opencollective.com/fiber/contributors.svg?width=890&button=false" alt="Code Contributors" style="max-width:100%;">
@ -644,6 +674,6 @@ Fiber is an open source project that runs on donations to pay the bills e.g. our
<img src="https://starchart.cc/gofiber/fiber.svg" alt="Stargazers over time" style="max-width: 100%">
## ⚠️ License
## 🧾 License
Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](https://github.com/gofiber/fiber/graphs/contributors). `Fiber` is free and open-source software licensed under the [MIT License](https://github.com/gofiber/fiber/blob/master/LICENSE). Official logo was created by [Vic Shóstak](https://github.com/koddr) and distributed under [Creative Commons](https://creativecommons.org/licenses/by-sa/4.0/) license (CC BY-SA 4.0 International).

View File

@ -34,7 +34,7 @@ jobs:
run: go install gotest.tools/gotestsum@v1.11.0
- name: Test
run: gotestsum -f testname -- ./... -race -count=1 -coverprofile=coverage.txt -covermode=atomic
run: gotestsum -f testname -- ./... -race -count=1 -coverprofile=coverage.txt -covermode=atomic -shuffle=on
- name: Upload coverage reports to Codecov
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.22.x' }}

4
.gitignore vendored
View File

@ -9,8 +9,8 @@
*.test
*.tmp
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Output of the go coverage tool
**/*.out
# IDE files
.vscode

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
## help: 💡 Display available commands
.PHONY: help
help:
@echo '⚡️ GoFiber/Fiber Development:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## audit: 🚀 Conduct quality checks
.PHONY: audit
audit:
go mod verify
go vet ./...
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
## benchmark: 📈 Benchmark code performance
.PHONY: benchmark
benchmark:
go test ./... -benchmem -bench=. -run=^Benchmark_$
## coverage: ☂️ Generate coverage report
.PHONY: coverage
coverage:
go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -coverprofile=/tmp/coverage.out -covermode=atomic
go tool cover -html=/tmp/coverage.out
## format: 🎨 Fix code format issues
.PHONY: format
format:
go run mvdan.cc/gofumpt@latest -w -l .
## lint: 🚨 Run lint checks
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1 run ./...
## test: 🚦 Execute all tests
.PHONY: test
test:
go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -shuffle=on
## tidy: 📌 Clean and tidy dependencies
.PHONY: tidy
tidy:
go mod tidy -v

View File

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestExponentialBackoff_Retry(t *testing.T) {
func Test_ExponentialBackoff_Retry(t *testing.T) {
t.Parallel()
tests := []struct {
name string
@ -60,7 +60,7 @@ func TestExponentialBackoff_Retry(t *testing.T) {
}
}
func TestExponentialBackoff_Next(t *testing.T) {
func Test_ExponentialBackoff_Next(t *testing.T) {
t.Parallel()
tests := []struct {
name string

View File

@ -1809,7 +1809,7 @@ func Test_App_AddCustomRequestMethod(t *testing.T) {
require.Equal(t, "TEST", appMethods[len(appMethods)-1])
}
func TestApp_GetRoutes(t *testing.T) {
func Test_App_GetRoutes(t *testing.T) {
t.Parallel()
app := New()
app.Use(func(c Ctx) error {

View File

@ -22,7 +22,7 @@ func checkKeyValue(t *testing.T, cj *CookieJar, cookie *fasthttp.Cookie, uri *fa
require.Equal(t, string(c.Value()), string(cookie.Value()))
}
func TestCookieJarGet(t *testing.T) {
func Test_CookieJarGet(t *testing.T) {
t.Parallel()
url := []byte("http://fasthttp.com/")
@ -97,7 +97,7 @@ func TestCookieJarGet(t *testing.T) {
}
}
func TestCookieJarGetExpired(t *testing.T) {
func Test_CookieJarGetExpired(t *testing.T) {
t.Parallel()
url1 := []byte("http://fasthttp.com/make/")
@ -116,7 +116,7 @@ func TestCookieJarGetExpired(t *testing.T) {
require.Empty(t, cookies)
}
func TestCookieJarSet(t *testing.T) {
func Test_CookieJarSet(t *testing.T) {
t.Parallel()
url := []byte("http://fasthttp.com/hello/world")
@ -133,7 +133,7 @@ func TestCookieJarSet(t *testing.T) {
checkKeyValue(t, cj, cookie, uri, 1)
}
func TestCookieJarSetRepeatedCookieKeys(t *testing.T) {
func Test_CookieJarSetRepeatedCookieKeys(t *testing.T) {
t.Parallel()
host := "fast.http"
cj := &CookieJar{}
@ -161,7 +161,7 @@ func TestCookieJarSetRepeatedCookieKeys(t *testing.T) {
require.True(t, bytes.Equal(cookies[0].Value(), cookie2.Value()))
}
func TestCookieJarSetKeyValue(t *testing.T) {
func Test_CookieJarSetKeyValue(t *testing.T) {
t.Parallel()
host := "fast.http"
@ -179,7 +179,7 @@ func TestCookieJarSetKeyValue(t *testing.T) {
require.Len(t, cookies, 2)
}
func TestCookieJarGetFromResponse(t *testing.T) {
func Test_CookieJarGetFromResponse(t *testing.T) {
t.Parallel()
res := fasthttp.AcquireResponse()

View File

@ -4561,8 +4561,8 @@ func Benchmark_Ctx_GetReqHeaders(b *testing.B) {
}, headers)
}
// go test -run Test_genericParseTypeInts
func Test_genericParseTypeInts(t *testing.T) {
// go test -run Test_GenericParseTypeInts
func Test_GenericParseTypeInts(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4615,8 +4615,8 @@ func Test_genericParseTypeInts(t *testing.T) {
}
}
// go test -run Test_genericParseTypeInt8s
func Test_genericParseTypeInt8s(t *testing.T) {
// go test -run Test_GenericParseTypeInt8s
func Test_GenericParseTypeInt8s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -4666,8 +4666,8 @@ func Test_genericParseTypeInt8s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeInt16s
func Test_genericParseTypeInt16s(t *testing.T) {
// go test -run Test_GenericParseTypeInt16s
func Test_GenericParseTypeInt16s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4716,8 +4716,8 @@ func Test_genericParseTypeInt16s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeInt32s
func Test_genericParseTypeInt32s(t *testing.T) {
// go test -run Test_GenericParseTypeInt32s
func Test_GenericParseTypeInt32s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4766,8 +4766,8 @@ func Test_genericParseTypeInt32s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeInt64s
func Test_genericParseTypeInt64s(t *testing.T) {
// go test -run Test_GenericParseTypeInt64s
func Test_GenericParseTypeInt64s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4816,8 +4816,8 @@ func Test_genericParseTypeInt64s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeUints
func Test_genericParseTypeUints(t *testing.T) {
// go test -run Test_GenericParseTypeUints
func Test_GenericParseTypeUints(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4858,8 +4858,8 @@ func Test_genericParseTypeUints(t *testing.T) {
}
}
// go test -run Test_genericParseTypeUints
func Test_genericParseTypeUint8s(t *testing.T) {
// go test -run Test_GenericParseTypeUints
func Test_GenericParseTypeUint8s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -4904,8 +4904,8 @@ func Test_genericParseTypeUint8s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeUint16s
func Test_genericParseTypeUint16s(t *testing.T) {
// go test -run Test_GenericParseTypeUint16s
func Test_GenericParseTypeUint16s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -4951,8 +4951,8 @@ func Test_genericParseTypeUint16s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeUint32s
func Test_genericParseTypeUint32s(t *testing.T) {
// go test -run Test_GenericParseTypeUint32s
func Test_GenericParseTypeUint32s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -4998,8 +4998,8 @@ func Test_genericParseTypeUint32s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeUint64s
func Test_genericParseTypeUint64s(t *testing.T) {
// go test -run Test_GenericParseTypeUint64s
func Test_GenericParseTypeUint64s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
value v
@ -5040,8 +5040,8 @@ func Test_genericParseTypeUint64s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeFloat32s
func Test_genericParseTypeFloat32s(t *testing.T) {
// go test -run Test_GenericParseTypeFloat32s
func Test_GenericParseTypeFloat32s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -5079,8 +5079,8 @@ func Test_genericParseTypeFloat32s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeFloat64s
func Test_genericParseTypeFloat64s(t *testing.T) {
// go test -run Test_GenericParseTypeFloat64s
func Test_GenericParseTypeFloat64s(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -5118,8 +5118,8 @@ func Test_genericParseTypeFloat64s(t *testing.T) {
}
}
// go test -run Test_genericParseTypeArrayBytes
func Test_genericParseTypeArrayBytes(t *testing.T) {
// go test -run Test_GenericParseTypeArrayBytes
func Test_GenericParseTypeArrayBytes(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -5157,8 +5157,8 @@ func Test_genericParseTypeArrayBytes(t *testing.T) {
}
}
// go test -run Test_genericParseTypeBoolean
func Test_genericParseTypeBoolean(t *testing.T) {
// go test -run Test_GenericParseTypeBoolean
func Test_GenericParseTypeBoolean(t *testing.T) {
t.Parallel()
type genericTypes[v GenericType] struct {
@ -5201,8 +5201,8 @@ func Test_genericParseTypeBoolean(t *testing.T) {
}
}
// go test -run Test_genericParseTypeString
func Test_genericParseTypeString(t *testing.T) {
// go test -run Test_GenericParseTypeString
func Test_GenericParseTypeString(t *testing.T) {
t.Parallel()
tests := []string{"john", "doe", "hello", "fiber"}
@ -5218,8 +5218,8 @@ func Test_genericParseTypeString(t *testing.T) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeInts -benchmem -count=4
func Benchmark_genericParseTypeInts(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeInts -benchmem -count=4
func Benchmark_GenericParseTypeInts(b *testing.B) {
type genericTypes[v GenericType] struct {
value v
str string
@ -5401,8 +5401,8 @@ func Benchmark_genericParseTypeInts(b *testing.B) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeUints -benchmem -count=4
func Benchmark_genericParseTypeUints(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeUints -benchmem -count=4
func Benchmark_GenericParseTypeUints(b *testing.B) {
type genericTypes[v GenericType] struct {
value v
str string
@ -5584,8 +5584,8 @@ func Benchmark_genericParseTypeUints(b *testing.B) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeFloats -benchmem -count=4
func Benchmark_genericParseTypeFloats(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeFloats -benchmem -count=4
func Benchmark_GenericParseTypeFloats(b *testing.B) {
type genericTypes[v GenericType] struct {
value v
str string
@ -5654,8 +5654,8 @@ func Benchmark_genericParseTypeFloats(b *testing.B) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeArrayBytes -benchmem -count=4
func Benchmark_genericParseTypeArrayBytes(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeArrayBytes -benchmem -count=4
func Benchmark_GenericParseTypeArrayBytes(b *testing.B) {
type genericTypes[v GenericType] struct {
value v
str string
@ -5681,7 +5681,7 @@ func Benchmark_genericParseTypeArrayBytes(b *testing.B) {
}
for _, test := range arrBytes {
b.Run("Benchmark_genericParseTypeArrayBytes", func(b *testing.B) {
b.Run("Benchmark_GenericParseTypeArrayBytes", func(b *testing.B) {
var res []byte
b.ReportAllocs()
b.ResetTimer()
@ -5693,8 +5693,8 @@ func Benchmark_genericParseTypeArrayBytes(b *testing.B) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeBoolean -benchmem -count=4
func Benchmark_genericParseTypeBoolean(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeBoolean -benchmem -count=4
func Benchmark_GenericParseTypeBoolean(b *testing.B) {
type genericTypes[v GenericType] struct {
value v
str string
@ -5720,7 +5720,7 @@ func Benchmark_genericParseTypeBoolean(b *testing.B) {
}
for _, test := range bools {
b.Run("Benchmark_genericParseTypeBoolean", func(b *testing.B) {
b.Run("Benchmark_GenericParseTypeBoolean", func(b *testing.B) {
var res bool
b.ReportAllocs()
b.ResetTimer()
@ -5736,8 +5736,8 @@ func Benchmark_genericParseTypeBoolean(b *testing.B) {
}
}
// go test -v -run=^$ -bench=Benchmark_genericParseTypeString -benchmem -count=4
func Benchmark_genericParseTypeString(b *testing.B) {
// go test -v -run=^$ -bench=Benchmark_GenericParseTypeString -benchmem -count=4
func Benchmark_GenericParseTypeString(b *testing.B) {
tests := []string{"john", "doe", "hello", "fiber"}
b.ReportAllocs()

View File

@ -9,66 +9,66 @@ import (
"github.com/stretchr/testify/require"
)
func TestConversionError(t *testing.T) {
func Test_ConversionError(t *testing.T) {
t.Parallel()
ok := errors.As(ConversionError{}, &schema.ConversionError{})
require.True(t, ok)
}
func TestUnknownKeyError(t *testing.T) {
func Test_UnknownKeyError(t *testing.T) {
t.Parallel()
ok := errors.As(UnknownKeyError{}, &schema.UnknownKeyError{})
require.True(t, ok)
}
func TestEmptyFieldError(t *testing.T) {
func Test_EmptyFieldError(t *testing.T) {
t.Parallel()
ok := errors.As(EmptyFieldError{}, &schema.EmptyFieldError{})
require.True(t, ok)
}
func TestMultiError(t *testing.T) {
func Test_MultiError(t *testing.T) {
t.Parallel()
ok := errors.As(MultiError{}, &schema.MultiError{})
require.True(t, ok)
}
func TestInvalidUnmarshalError(t *testing.T) {
func Test_InvalidUnmarshalError(t *testing.T) {
t.Parallel()
var e *json.InvalidUnmarshalError
ok := errors.As(&InvalidUnmarshalError{}, &e)
require.True(t, ok)
}
func TestMarshalerError(t *testing.T) {
func Test_MarshalerError(t *testing.T) {
t.Parallel()
var e *json.MarshalerError
ok := errors.As(&MarshalerError{}, &e)
require.True(t, ok)
}
func TestSyntaxError(t *testing.T) {
func Test_SyntaxError(t *testing.T) {
t.Parallel()
var e *json.SyntaxError
ok := errors.As(&SyntaxError{}, &e)
require.True(t, ok)
}
func TestUnmarshalTypeError(t *testing.T) {
func Test_UnmarshalTypeError(t *testing.T) {
t.Parallel()
var e *json.UnmarshalTypeError
ok := errors.As(&UnmarshalTypeError{}, &e)
require.True(t, ok)
}
func TestUnsupportedTypeError(t *testing.T) {
func Test_UnsupportedTypeError(t *testing.T) {
t.Parallel()
var e *json.UnsupportedTypeError
ok := errors.As(&UnsupportedTypeError{}, &e)
require.True(t, ok)
}
func TestUnsupportedValeError(t *testing.T) {
func Test_UnsupportedValeError(t *testing.T) {
t.Parallel()
var e *json.UnsupportedValueError
ok := errors.As(&UnsupportedValueError{}, &e)

View File

@ -8,7 +8,7 @@ import (
"github.com/tinylib/msgp/msgp"
)
func TestMarshalUnmarshalitem(t *testing.T) {
func Test_MarshalUnmarshalitem(t *testing.T) {
v := item{}
bts, err := v.MarshalMsg(nil)
if err != nil {
@ -31,7 +31,7 @@ func TestMarshalUnmarshalitem(t *testing.T) {
}
}
func BenchmarkMarshalMsgitem(b *testing.B) {
func Benchmark_MarshalMsgitem(b *testing.B) {
v := item{}
b.ReportAllocs()
b.ResetTimer()
@ -40,7 +40,7 @@ func BenchmarkMarshalMsgitem(b *testing.B) {
}
}
func BenchmarkAppendMsgitem(b *testing.B) {
func Benchmark_AppendMsgitem(b *testing.B) {
v := item{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
@ -52,7 +52,7 @@ func BenchmarkAppendMsgitem(b *testing.B) {
}
}
func BenchmarkUnmarshalitem(b *testing.B) {
func Benchmark_Unmarshalitem(b *testing.B) {
v := item{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()

View File

@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert"
)
// go test -run -v Test_normalizeOrigin
func Test_normalizeOrigin(t *testing.T) {
// go test -run -v Test_NormalizeOrigin
func Test_NormalizeOrigin(t *testing.T) {
testCases := []struct {
origin string
expectedValid bool
@ -52,8 +52,8 @@ func Test_normalizeOrigin(t *testing.T) {
}
}
// go test -run -v Test_matchScheme
func Test_matchScheme(t *testing.T) {
// go test -run -v Test_MatchScheme
func Test_MatchScheme(t *testing.T) {
testCases := []struct {
domain string
pattern string
@ -80,8 +80,8 @@ func Test_matchScheme(t *testing.T) {
}
}
// go test -run -v Test_normalizeDomain
func Test_normalizeDomain(t *testing.T) {
// go test -run -v Test_NormalizeDomain
func Test_NormalizeDomain(t *testing.T) {
testCases := []struct {
input string
expectedOutput string

View File

@ -8,7 +8,7 @@ import (
"github.com/tinylib/msgp/msgp"
)
func TestMarshalUnmarshalitem(t *testing.T) {
func Test_MarshalUnmarshalitem(t *testing.T) {
v := item{}
bts, err := v.MarshalMsg(nil)
if err != nil {
@ -31,7 +31,7 @@ func TestMarshalUnmarshalitem(t *testing.T) {
}
}
func BenchmarkMarshalMsgitem(b *testing.B) {
func Benchmark_MarshalMsgitem(b *testing.B) {
v := item{}
b.ReportAllocs()
b.ResetTimer()
@ -40,7 +40,7 @@ func BenchmarkMarshalMsgitem(b *testing.B) {
}
}
func BenchmarkAppendMsgitem(b *testing.B) {
func Benchmark_AppendMsgitem(b *testing.B) {
v := item{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
@ -52,7 +52,7 @@ func BenchmarkAppendMsgitem(b *testing.B) {
}
}
func BenchmarkUnmarshalitem(b *testing.B) {
func Benchmark_Unmarshalitem(b *testing.B) {
v := item{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()

View File

@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestEnvVarStructWithExportVarsExcludeVars(t *testing.T) {
func Test_EnvVarStructWithExportVarsExcludeVars(t *testing.T) {
t.Setenv("testKey", "testEnvValue")
t.Setenv("anotherEnvKey", "anotherEnvVal")
t.Setenv("excludeKey", "excludeEnvValue")
@ -27,7 +27,7 @@ func TestEnvVarStructWithExportVarsExcludeVars(t *testing.T) {
require.Equal(t, "", vars.Vars["anotherEnvKey"])
}
func TestEnvVarHandler(t *testing.T) {
func Test_EnvVarHandler(t *testing.T) {
t.Setenv("testKey", "testVal")
expectedEnvVarResponse, err := json.Marshal(
@ -54,7 +54,7 @@ func TestEnvVarHandler(t *testing.T) {
require.Equal(t, expectedEnvVarResponse, respBody)
}
func TestEnvVarHandlerNotMatched(t *testing.T) {
func Test_EnvVarHandlerNotMatched(t *testing.T) {
app := fiber.New()
app.Use("/envvars", New(Config{
ExportVars: map[string]string{"testKey": ""},
@ -76,7 +76,7 @@ func TestEnvVarHandlerNotMatched(t *testing.T) {
require.Equal(t, []byte("OK"), respBody)
}
func TestEnvVarHandlerDefaultConfig(t *testing.T) {
func Test_EnvVarHandlerDefaultConfig(t *testing.T) {
t.Setenv("testEnvKey", "testEnvVal")
app := fiber.New()
@ -96,7 +96,7 @@ func TestEnvVarHandlerDefaultConfig(t *testing.T) {
require.Equal(t, "testEnvVal", val)
}
func TestEnvVarHandlerMethod(t *testing.T) {
func Test_EnvVarHandlerMethod(t *testing.T) {
app := fiber.New()
app.Use("/envvars", New())
@ -107,7 +107,7 @@ func TestEnvVarHandlerMethod(t *testing.T) {
require.Equal(t, fiber.StatusMethodNotAllowed, resp.StatusCode)
}
func TestEnvVarHandlerSpecialValue(t *testing.T) {
func Test_EnvVarHandlerSpecialValue(t *testing.T) {
testEnvKey := "testEnvKey"
fakeBase64 := "testBase64:TQ=="
t.Setenv(testEnvKey, fakeBase64)

View File

@ -31,7 +31,7 @@ func TestMarshalUnmarshalresponse(t *testing.T) {
}
}
func BenchmarkMarshalMsgresponse(b *testing.B) {
func Benchmark_MarshalMsgresponse(b *testing.B) {
v := response{}
b.ReportAllocs()
b.ResetTimer()
@ -40,7 +40,7 @@ func BenchmarkMarshalMsgresponse(b *testing.B) {
}
}
func BenchmarkAppendMsgresponse(b *testing.B) {
func Benchmark_AppendMsgresponse(b *testing.B) {
v := response{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
@ -52,7 +52,7 @@ func BenchmarkAppendMsgresponse(b *testing.B) {
}
}
func BenchmarkUnmarshalresponse(b *testing.B) {
func Benchmark_Unmarshalresponse(b *testing.B) {
v := response{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()

View File

@ -14,7 +14,7 @@ import (
const CorrectKey = "specials: !$%,.#\"!?~`<>@$^*(){}[]|/\\123"
func TestAuthSources(t *testing.T) {
func Test_AuthSources(t *testing.T) {
// define test cases
testSources := []string{"header", "cookie", "query", "param", "form"}
@ -130,7 +130,7 @@ func TestAuthSources(t *testing.T) {
}
}
func TestMultipleKeyAuth(t *testing.T) {
func Test_MultipleKeyAuth(t *testing.T) {
// setup the fiber endpoint
app := fiber.New()
@ -261,7 +261,7 @@ func TestMultipleKeyAuth(t *testing.T) {
}
}
func TestCustomSuccessAndFailureHandlers(t *testing.T) {
func Test_CustomSuccessAndFailureHandlers(t *testing.T) {
app := fiber.New()
app.Use(New(Config{
@ -314,7 +314,7 @@ func TestCustomSuccessAndFailureHandlers(t *testing.T) {
require.Equal(t, "API key is valid and request was handled by custom success handler", string(body))
}
func TestCustomNextFunc(t *testing.T) {
func Test_CustomNextFunc(t *testing.T) {
app := fiber.New()
app.Use(New(Config{
@ -376,7 +376,7 @@ func TestCustomNextFunc(t *testing.T) {
require.Equal(t, string(body), ErrMissingOrMalformedAPIKey.Error())
}
func TestAuthSchemeToken(t *testing.T) {
func Test_AuthSchemeToken(t *testing.T) {
app := fiber.New()
app.Use(New(Config{
@ -411,7 +411,7 @@ func TestAuthSchemeToken(t *testing.T) {
require.Equal(t, "API key is valid", string(body))
}
func TestAuthSchemeBasic(t *testing.T) {
func Test_AuthSchemeBasic(t *testing.T) {
app := fiber.New()
app.Use(New(Config{

View File

@ -8,7 +8,7 @@ import (
"github.com/tinylib/msgp/msgp"
)
func TestMarshalUnmarshalitem(t *testing.T) {
func Test_MarshalUnmarshalitem(t *testing.T) {
v := item{}
bts, err := v.MarshalMsg(nil)
if err != nil {
@ -31,7 +31,7 @@ func TestMarshalUnmarshalitem(t *testing.T) {
}
}
func BenchmarkMarshalMsgitem(b *testing.B) {
func Benchmark_MarshalMsgitem(b *testing.B) {
v := item{}
b.ReportAllocs()
b.ResetTimer()
@ -40,7 +40,7 @@ func BenchmarkMarshalMsgitem(b *testing.B) {
}
}
func BenchmarkAppendMsgitem(b *testing.B) {
func Benchmark_AppendMsgitem(b *testing.B) {
v := item{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
@ -52,7 +52,7 @@ func BenchmarkAppendMsgitem(b *testing.B) {
}
}
func BenchmarkUnmarshalitem(b *testing.B) {
func Benchmark_Unmarshalitem(b *testing.B) {
v := item{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()

View File

@ -9,8 +9,8 @@ import (
"github.com/valyala/fasthttp"
)
// go test -run TestStore_getSessionID
func TestStore_getSessionID(t *testing.T) {
// go test -run Test_Store_getSessionID
func Test_Store_getSessionID(t *testing.T) {
t.Parallel()
expectedID := "test-session-id"
@ -61,9 +61,9 @@ func TestStore_getSessionID(t *testing.T) {
})
}
// go test -run TestStore_Get
// go test -run Test_Store_Get
// Regression: https://github.com/gofiber/fiber/issues/1408
func TestStore_Get(t *testing.T) {
func Test_Store_Get(t *testing.T) {
t.Parallel()
unexpectedID := "test-session-id"
// fiber instance
@ -85,8 +85,8 @@ func TestStore_Get(t *testing.T) {
})
}
// go test -run TestStore_DeleteSession
func TestStore_DeleteSession(t *testing.T) {
// go test -run Test_Store_DeleteSession
func Test_Store_DeleteSession(t *testing.T) {
t.Parallel()
// fiber instance
app := fiber.New()