Add comprehensive test coverage for Lambda Labs error handling functions #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive test coverage for Lambda Labs error handling functions
Summary
This PR adds comprehensive test coverage for the previously untested error handling functions in the Lambda Labs implementation:
handleAPIErrorandhandleErrToCloudErr. The new test suite covers various HTTP error scenarios, API error transformations, and edge cases to ensure robust error handling behavior.Key Changes:
internal/lambdalabs/v1/errors_test.gowith 13 test functions covering both error handling functionsopenapi.GenericOpenAPIErrorfieldsErrInsufficientResources, region errors, etc.)Review & Testing Checklist for Human
go test ./internal/lambdalabs/v1 -vpasses and all error test cases work as expectedopenapi.GenericOpenAPIErrorprivate fields is appropriate and won't break with future changesRecommended Test Plan: Run the full test suite locally and verify that the error handling behaves correctly for typical Lambda Labs API failure scenarios.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD errors_go["internal/lambdalabs/v1/<br/>errors.go"]:::context errors_test_go["internal/lambdalabs/v1/<br/>errors_test.go"]:::major-edit pkg_errors_go["pkg/v1/<br/>errors.go"]:::context openapi_client["internal/lambdalabs/gen/<br/>lambdalabs/client.go"]:::context go_mod["go.mod"]:::minor-edit go_sum["go.sum"]:::minor-edit errors_test_go -->|"tests"| errors_go errors_test_go -->|"imports error types"| pkg_errors_go errors_test_go -->|"uses GenericOpenAPIError<br/>with reflection"| openapi_client errors_test_go -->|"test dependencies"| go_mod go_mod -->|"dependency lock"| go_sum subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
GenericOpenAPIErroris necessary because the struct has private fields, but it's brittle and should be monitored for future OpenAPI client updatesLink to Devin run: https://app.devin.ai/sessions/ff49c2c138e847398cb946898211a43f
Requested by: Alec Fong (@theFong)