Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Expand unit-tests for the middleware, fix panic caused by empty default configuration #82

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

gaby
Copy link
Member

@gaby gaby commented Jan 16, 2023

Completed:

  • Fixed panic caused by passing an empty config to redirect.New()
  • Added unit-tests for Filter function.
  • Added unit-tests for Regex Rules.
  • Added unit-tests for default config
  • Coverage report is now at 100% of statements
  • Added go 1.19.x to test suite

Fixes:

Results:

ubuntu@ubuntu:~/Desktop/git/fix/redirect$ go test -cover ./...
ok  	github.com/gofiber/redirect/v2	(cached)	coverage: 100.0% of statements
ubuntu@ubuntu:~/Desktop/git/fix/redirect$ go test -v ./...
=== RUN   Test_Redirect
=== RUN   Test_Redirect/should_be_returns_status_302_without_a_wildcard
=== RUN   Test_Redirect/should_be_returns_status_307_using_wildcard
=== RUN   Test_Redirect/should_be_returns_status_303_without_set_redirectTo_to_use_the_default
=== RUN   Test_Redirect/should_return_the_status_code_default
=== RUN   Test_Redirect/access_URL_without_rule
=== RUN   Test_Redirect/redirect_to_swagger_route
=== RUN   Test_Redirect/no_redirect_to_swagger_route
=== RUN   Test_Redirect/no_redirect_to_swagger_route_#2
--- PASS: Test_Redirect (0.00s)
    --- PASS: Test_Redirect/should_be_returns_status_302_without_a_wildcard (0.00s)
    --- PASS: Test_Redirect/should_be_returns_status_307_using_wildcard (0.00s)
    --- PASS: Test_Redirect/should_be_returns_status_303_without_set_redirectTo_to_use_the_default (0.00s)
    --- PASS: Test_Redirect/should_return_the_status_code_default (0.00s)
    --- PASS: Test_Redirect/access_URL_without_rule (0.00s)
    --- PASS: Test_Redirect/redirect_to_swagger_route (0.00s)
    --- PASS: Test_Redirect/no_redirect_to_swagger_route (0.00s)
    --- PASS: Test_Redirect/no_redirect_to_swagger_route_#2 (0.00s)
=== RUN   Test_Filter
--- PASS: Test_Filter (0.00s)
=== RUN   Test_NoRules
--- PASS: Test_NoRules (0.00s)
=== RUN   Test_DefaultConfig
--- PASS: Test_DefaultConfig (0.00s)
=== RUN   Test_RegexRules
    main_test.go:292: Recovered from invalid regex:  regexp: Compile(`($`): error parsing regexp: missing closing ): `($`
--- PASS: Test_RegexRules (0.00s)
PASS
ok  	github.com/gofiber/redirect/v2	(cached)

…ex and default configs

Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
@github-actions github-actions bot added ☢️ Bug Something isn't working 🧹 Updates labels Jan 16, 2023
Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
@ReneWerner87 ReneWerner87 merged commit 271a362 into master Jan 16, 2023
@gaby gaby deleted the expand-tests branch January 16, 2023 23:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
☢️ Bug Something isn't working 🧹 Updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants