Conversation
- Add httpmock dependency for HTTP request mocking - Create comprehensive test suite covering all Lambda Labs client methods: - Credential methods (GetReferenceID, GetAPIType, GetCloudProviderID, etc.) - Client methods (CreateInstance, GetInstance, ListInstances, TerminateInstance, RebootInstance) - Helper functions (convertLambdaLabsInstanceToV1Instance, convertLambdaLabsStatusToV1Status) - Capabilities and merge functions - Mock all Lambda Labs API endpoints with realistic OpenAPI response structures - Test both success and error scenarios for each method - Use proper OpenAPI models for mock responses to ensure realistic testing - Add constants for repeated test values to satisfy linting requirements - All 28 tests pass successfully with comprehensive coverage Co-Authored-By: Alec Fong <alecsanf@usc.edu>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Member
|
Please break up client_test.go into smaller files. like capabilities_test.go instance_test.go etc |
- Break up 483-line client_test.go into 6 focused test files - common_test.go: shared utilities and constants - credential_test.go: 5 credential tests - client_test.go: 5 basic client tests - instance_test.go: 13 instance operation tests - capabilities_test.go: 2 capabilities tests - helpers_test.go: 4 helper function tests - Maintain all 28 tests with proper imports and dependencies - Address GitHub feedback from @theFong on PR #7 Co-Authored-By: Alec Fong <alecsanf@usc.edu>
theFong
requested changes
Aug 5, 2025
Member
theFong
left a comment
There was a problem hiding this comment.
are we missing get instance type test? Can you add that?
- Add tests for GetInstanceTypes with success, filtering, and error cases - Add tests for GetInstanceTypePollTime method - Add tests for helper functions convertLambdaLabsInstanceTypeToV1InstanceType and parseGPUFromDescription - Mock /api/v1/instance-types endpoint with realistic response data - Test location and instance type filtering functionality - Address GitHub feedback from @theFong on PR #7 Co-Authored-By: Alec Fong <alecsanf@usc.edu>
theFong
approved these changes
Aug 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 unit tests for GetInstanceTypes method
Summary
This PR adds comprehensive unit tests for the Lambda Labs provider's
GetInstanceTypesmethod and related helper functions, addressing feedback from @theFong on PR #7. The tests are organized in a newinstancetype_test.gofile to logically separate instance type operations from instance lifecycle tests.Key additions:
GetInstanceTypeswith success, error, and filtering scenariosGetInstanceTypePollTimemethodconvertLambdaLabsInstanceTypeToV1InstanceTypeandparseGPUFromDescription/api/v1/instance-typesendpoint with realistic OpenAPI response structureReview & Testing Checklist for Human
/api/v1/instance-typesendpoint structure, including all required OpenAPI fieldsparseGPUFromDescriptionregex patterns were adjusted multiple times during development; validate they work with actual Lambda Labs instance type descriptionsRecommended test plan: Run the tests against a staging Lambda Labs environment to verify mock responses match reality, then test filtering scenarios with various location and instance type combinations.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD A["internal/lambdalabs/v1/<br/>instancetype.go"]:::context B["internal/lambdalabs/v1/<br/>instancetype_test.go"]:::major-edit C["internal/lambdalabs/v1/<br/>common_test.go"]:::context D["pkg/v1/<br/>instancetype.go"]:::context E["OpenAPI Models"]:::context A -->|implements| D B -->|tests| A B -->|uses setup from| C B -->|mocks| E A -->|uses| E B -->|"HTTP mocks<br/>/api/v1/instance-types"| A B -->|"Tests filtering<br/>and conversion"| A 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