Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router issue #478

Closed
tib opened this issue Jun 17, 2024 · 2 comments
Closed

Router issue #478

tib opened this issue Jun 17, 2024 · 2 comments

Comments

@tib
Copy link
Contributor

tib commented Jun 17, 2024

Hi,

I believe I discovered a router issue in HB2beta, given the following router setup:

import Hummingbird

func buildApplication(
    configuration: ApplicationConfiguration
) -> some ApplicationProtocol {
    let router = Router()
    
    router.get("/foo/bar") { _, _ in "foo-bar"}
    router.get("/foo/{id}/baz") { _, _ in "foo-bar-baz" }

    let app = Application(
        router: router,
        configuration: configuration
    )
    return app
}

Using this test case:

@testable import App
import Hummingbird
import HummingbirdTesting
import XCTest

final class AppTests: XCTestCase {

    func testApp() async throws {
        let app = buildApplication(
            configuration: .init()
        )
        try await app.test(.live) { client in
            
            try await client.execute(
                uri: "/foo/bar/baz",
                method: .get
            ) { response in
                XCTAssertEqual(response.status, .ok)
                XCTAssertEqual(String(buffer: response.body), "foo-bar-baz")
            }
        }
    }
}

The test fails with a 404 response, but I'm expecting the router to resolve a route for the foo/bar/baz request and bar should be the value of the {id}.

Is this a real issue or am I doing something wrong?

Thank you for the help.
Tib

@adam-fowler
Copy link
Member

Looks like the rewinding of the router path stack isn't working. It is an issue, we'll look into it.

@adam-fowler
Copy link
Member

@Joannis has fixed this in #479

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

No branches or pull requests

2 participants