Skip to content

Add tests for panic behavior on malformed route patterns#1066

Open
fheikens wants to merge 2 commits intogo-chi:masterfrom
fheikens:panic-tests
Open

Add tests for panic behavior on malformed route patterns#1066
fheikens wants to merge 2 commits intogo-chi:masterfrom
fheikens:panic-tests

Conversation

@fheikens
Copy link
Copy Markdown

Summary

Adds test coverage for five existing panic guard paths in route pattern
validation that were not explicitly covered by tests. No production code was changed.

Covered cases:

  • Unclosed { brace in route pattern (tree.go:patNextSegment)
  • Duplicate parameter keys in pattern (tree.go:patParamKeys) — addresses the TODO at tree_test.go:194
  • Invalid regexp in route parameter (tree.go:addChild)
  • Route() called with nil function (mux.go:Route)
  • Mount() called with nil handler (mux.go:Mount)

Test plan

  • All five new tests pass: go test -v -run TestPanic ./...
  • Full test suite passes: go test ./...
  • No production code modified

@fheikens
Copy link
Copy Markdown
Author

Good point — tightened the pattern to {id:(abc} (unclosed group) so the failure is unambiguously from regexp.Compile, not from route pattern parsing. Test name stays accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant