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

Error when unknown API endpoint is used in testserver #2292

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Feb 4, 2025

Changes

This PR fails the acceptance test when an unknown endpoint (i.e. not stubbed) is used.

Tests

Manually:

output.txt when an endpoint is not found:

>>> [CLI] jobs create --json {"name":"abc"}
Error: No stub found for pattern: POST /api/2.1/jobs/create

How this renders in the test logs:

    --- FAIL: TestAccept/workspace/jobs/create (0.03s)
        server.go:46: 
            
            ----------------------------------------
            No stub found for pattern: POST /api/2.1/jobs/create
            
            To stub a response for this request, you can add
            the following to test.toml:
            [[Server]]
            Pattern = "POST /api/2.1/jobs/create"
            Response.Body = '''
            <response body here>
            '''
            Response.StatusCode = <response status-code here>
            ----------------------------------------

Manually checked that the debug mode still works.

@@ -90,8 +90,4 @@ func AddHandlers(server *testserver.Server) {
},
}, http.StatusOK
})

server.Handle("POST /api/2.0/workspace/mkdirs", func(r *http.Request) (any, int) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer needed

@shreyas-goenka shreyas-goenka marked this pull request as ready for review February 4, 2025 17:29
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