Description:
The recommendation engine (backend/internal/services/recommendations/engine.go) currently contains logic for generating sample recommendations and calculating potential savings. However, there are no unit tests to ensure that the savings calculations are correct and that the engine behaves as expected when given different inputs.
We should add basic unit tests that mock the database repositories and verify that:
- Rightsizing recommendations are created when expected.
- Potential savings are calculated correctly.
- Idle resource recommendations are generated properly.
Acceptance Criteria:
- Create engine_test.go in the same package.
- Use table-driven tests for different scenarios.
- Mock the repository interfaces (use gomock or write simple struct mocks).
- Test at least two functions (e.g., GenerateRightsizingRecommendations, calculateSavings).
- Ensure tests pass with go test ./....
- No external API calls (all mocked).
Files to change: backend/internal/services/recommendations/engine_test.go (new file), plus possibly minor refactoring to make code testable.
Description:
The recommendation engine (backend/internal/services/recommendations/engine.go) currently contains logic for generating sample recommendations and calculating potential savings. However, there are no unit tests to ensure that the savings calculations are correct and that the engine behaves as expected when given different inputs.
We should add basic unit tests that mock the database repositories and verify that:
Acceptance Criteria:
Files to change: backend/internal/services/recommendations/engine_test.go (new file), plus possibly minor refactoring to make code testable.