Skip to content

🧹 chore: Improve OPTIONS wildcard regression test#3869

Merged
ReneWerner87 merged 2 commits intomainfrom
add-regression-test-for-options-wildcard-handler
Nov 16, 2025
Merged

🧹 chore: Improve OPTIONS wildcard regression test#3869
ReneWerner87 merged 2 commits intomainfrom
add-regression-test-for-options-wildcard-handler

Conversation

@gaby
Copy link
Member

@gaby gaby commented Nov 16, 2025

Summary

  • add a small helper to write raw OPTIONS requests in Test_App_OptionsAsterisk
  • assert the wildcard and resource-specific handlers both return zero-length bodies via the ContentLength checks

@gaby gaby requested a review from a team as a code owner November 16, 2025 03:04
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a unit test that sends OPTIONS requests to both the wildcard ("*") target and a specific path ("/resource") using an in-memory listener, asserting response status codes, Allow headers, empty bodies, and proper connection shutdown.

Changes

Cohort / File(s) Summary
OPTIONS Request Test
app_test.go
Adds Test_App_OptionsAsterisk, which exercises OPTIONS handling for * and /resource, verifying response statuses (200 for *, 204 for /resource), Allow headers ("GET, POST"), empty response bodies, per-connection request writing, and connection closure behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test (client)
    participant Listener as In-memory Listener
    participant Server as HTTP Server
    Note right of Test `#E8F5E9`: New test opens connections\nand writes raw OPTIONS requests
    Test->>Listener: Open TCP connection + write "OPTIONS * HTTP/1.1\r\n..."
    Listener->>Server: Deliver request
    Server-->>Listener: Respond 200 OK + Allow header
    Listener-->>Test: Return response bytes
    Test->>Listener: Open TCP connection + write "OPTIONS /resource HTTP/1.1\r\n..."
    Listener->>Server: Deliver request
    Server-->>Listener: Respond 204 No Content + Allow header
    Listener-->>Test: Return response bytes
    Note left of Test `#FFF3E0`: Test asserts headers, statuses,\nand that bodies are empty and connections closed
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single new test function in one file, straightforward assertions.
  • Areas to check:
    • Correctness of raw request formatting for OPTIONS *.
    • Proper teardown/shutdown sequencing to avoid flakiness.

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • efectn

Poem

🐰 I nibble keys and run the test,

OPTIONS * and routes addressed,
Allow lines bright, responses neat,
Connections closed — a tidy feat. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is minimal and lacks required sections from the template (Changes introduced, Type of change, Checklist). While it briefly explains what was added, it does not follow the repository's description template structure. Expand the description to follow the template structure, including the 'Changes introduced' and 'Type of change' sections to clarify this is a test improvement and code consistency enhancement.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve OPTIONS wildcard regression test' is specific and directly related to the main change—adding and enhancing tests for OPTIONS wildcard handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-regression-test-for-options-wildcard-handler

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a26fc03 and 6f6c0cf.

📒 Files selected for processing (1)
  • app_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: unit (1.25.x, ubuntu-latest)
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: unit (1.25.x, macos-latest)
  • GitHub Check: repeated
  • GitHub Check: lint
  • GitHub Check: Compare
  • GitHub Check: update_release_draft

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gaby, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the testing suite by adding a new regression test for the OPTIONS HTTP method. The test specifically targets the correct behavior of both wildcard and resource-specific OPTIONS handlers, ensuring they return responses with zero content length. This enhancement bolsters the application's compliance with HTTP standards and its overall routing robustness.

Highlights

  • New Regression Test for OPTIONS: Introduces "Test_App_OptionsAsterisk" to validate the application's handling of HTTP OPTIONS requests for both wildcard (*) and specific resource paths.
  • Raw Request Helper: Adds a small helper function "writeRequest" within the test to construct and send raw OPTIONS HTTP requests, ensuring precise control over test scenarios.
  • Content-Length Assertions: Includes explicit assertions to verify that both wildcard and resource-specific OPTIONS handlers correctly return responses with a zero "ContentLength", aligning with HTTP best practices for such requests.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gaby gaby changed the title Improve OPTIONS wildcard regression test 🧹chore: Improve OPTIONS wildcard regression test Nov 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the OPTIONS wildcard (*) regression test by adding a dedicated test function that validates both wildcard and resource-specific OPTIONS handlers return zero-length response bodies.

Key changes:

  • Added Test_App_OptionsAsterisk with raw HTTP request capabilities
  • Introduced a helper function writeRequest for writing raw OPTIONS requests
  • Added assertions to verify ContentLength is zero for both wildcard and resource-specific handlers

@gaby gaby changed the title 🧹chore: Improve OPTIONS wildcard regression test 🧹 chore: Improve OPTIONS wildcard regression test Nov 16, 2025
@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.67%. Comparing base (db2576e) to head (6f6c0cf).
⚠️ Report is 52 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3869      +/-   ##
==========================================
- Coverage   91.69%   91.67%   -0.03%     
==========================================
  Files         115      115              
  Lines        9819     9819              
==========================================
- Hits         9004     9002       -2     
- Misses        516      517       +1     
- Partials      299      300       +1     
Flag Coverage Δ
unittests 91.67% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the regression test for OPTIONS requests with a wildcard. A new test Test_App_OptionsAsterisk is added, which correctly verifies the behavior for both wildcard and resource-specific OPTIONS handlers. My review focuses on improving the structure and robustness of the new test by refactoring it to eliminate code duplication and ensure proper resource cleanup. Overall, the change is good and the logic is sound.

@gaby gaby added the v3 label Nov 16, 2025
@ReneWerner87 ReneWerner87 added this to v3 Nov 16, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Nov 16, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf25e8 and a26fc03.

📒 Files selected for processing (1)
  • app_test.go (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • app_test.go
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • app_test.go
🧬 Code graph analysis (1)
app_test.go (2)
app.go (1)
  • New (523-636)
constants.go (4)
  • HeaderAllow (231-231)
  • StatusNoContent (56-56)
  • StatusOK (52-52)
  • MethodOptions (12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: unit (1.25.x, macos-latest)
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: repeated
  • GitHub Check: Compare
  • GitHub Check: lint
  • GitHub Check: update_release_draft
🔇 Additional comments (4)
app_test.go (4)

1426-1441: Well-structured OPTIONS handlers.

The test correctly validates both wildcard and resource-specific OPTIONS handling. The handlers appropriately set status codes and Allow headers without writing body content, which aligns with OPTIONS semantics.


1455-1459: LGTM: Well-designed helper function.

The helper properly uses t.Helper() and handles errors correctly, improving test readability.


1461-1475: Comprehensive validation of OPTIONS * behavior.

The test correctly validates the wildcard OPTIONS handler response, checking status, Allow header, and ContentLength as described in the PR objectives. Proper resource cleanup is in place.


1477-1492: Proper validation of resource-specific OPTIONS handler.

The control case correctly validates the /resource OPTIONS handler with appropriate assertions for 204 No Content status and empty body. The naming (controlConn, controlResp, controlBody) clearly distinguishes this from the wildcard test case.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@ReneWerner87 ReneWerner87 merged commit 686ca6d into main Nov 16, 2025
16 checks passed
@ReneWerner87 ReneWerner87 deleted the add-regression-test-for-options-wildcard-handler branch November 16, 2025 17:50
@github-project-automation github-project-automation bot moved this to Done in v3 Nov 16, 2025
@gaby gaby added the 📜 RFC Compliance Feature, implementation, or contribution adheres to relevant RFC standards. label Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex 📜 RFC Compliance Feature, implementation, or contribution adheres to relevant RFC standards. 🧹 Updates v3

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants