Skip to content

Write unit tests for the recommendation engine's cost calculation logic #3

Description

@oseghalep

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.

Activity

  1. wipheg commented on Jun 8, 2026

    @wipheg
    Contributor

    Hi @oseghalep , I’d like to work on this issue.
    I’ll add unit tests for the recommendation engine and keep the changes focused around the new test file.
    Could you please assign it to me?

  2. oseghalep commented on Jun 15, 2026

    @oseghalep
    OwnerAuthor

    @wipheg Issue Assigned to yourself

  3. wipheg commented on Jun 21, 2026

    @wipheg
    Contributor

    Closed by #39

  4. wipheg commented on Jul 5, 2026

    @wipheg
    Contributor

    Hi @oseghalep,

    PR #39 has already been merged. Would you mind closing this issue if everything looks good?

    Thanks!

  5. oseghalep commented on Jul 13, 2026

    @oseghalep
    OwnerAuthor

    🏆 HISTORY MADE! 🏆

    Congratulations @wipheg – you are officially the FIRST CONTRIBUTOR to Cloud Cost Optimization Hub! 🎉🚀

    Your PR has been merged and is now live in production!

    What you accomplished:

    ✅ Added comprehensive unit tests for the recommendation engine

    ✅ Refactored the codebase to be more testable with mock repositories

    ✅ Covered rightsizing, idle resource, and error scenarios

    ✅ Set a high standard for future contributions

    This is a huge milestone for the project, and we're grateful to have you as our first contributor. Your work will help ensure the recommendation engine remains reliable as we grow.

    🎁 $25 Amazon Gift Card

    As promised, your $25 Amazon gift card is on its way to the email address associated with your GitHub account. You should receive it within 24-48 hours. If you don't see it, please reply here or DM me and I'll follow up.

    Thank you for helping build this project!

    You've set the bar high for future contributors. We'd love to have you back – there are more good-first-issue tasks waiting if you're interested in continuing to contribute.

    🚀 Welcome to the contributor community!

  6. oseghalep commented on Jul 22, 2026

    @oseghalep
    OwnerAuthor

    Hi @wipheg ! Thank you again for your amazing contributions across three issues. I'm ready to send your $25 gift card. Could you please let me know the email address you'd like me to send it to? You can DM me or reply here. Thanks!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions