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

🧪 Improve Quality and Coverage of Unit Tests in modernisation-platform-instance-scheduler #6687

Open
6 tasks
connormaglynn opened this issue Apr 3, 2024 · 1 comment
Assignees
Labels
code quality go Pull requests that update Go code technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. testing

Comments

@connormaglynn
Copy link
Contributor

connormaglynn commented Apr 3, 2024

User Story

As a Modernisation Platform Engineer
I expect to have a high confidence that unit tests will capture any errors in my code
So that I can be confident my changes do not contain bugs or unintended breaking changes

Value / Purpose

The value of increasing the unit test coverage in the instance scheduler is to ensure engineers can be aware sooner if their changes break anything since unit tests are quick and easy to run locally.

This also has the benefit of being less dependent on our current integration testing process to capture bugs, meaning we can start to move away from this implementation of quality assurance.

Ideally, as well, properly unit testing the code will help highlight areas of the code that can/should be refactored to be more modular, less coupled and ultimately easier to test, read and understand.

Useful Contacts

No response

Additional Information

go test -coverprofile=coverage.out && go tool cover -html="coverage.out"

Proposal / Unknowns

Hypothesis If we... [do a thing] Then... [this will happ]

Proposal A proposal that is something testable, don't worry whether it works or not, it's a place for ideas.

Unknowns Potential pitfalls that could cause the story to expand beyond its original scope. Ideally this section will remain blank.

Definition of Done

  • Unit test coverage is ~95% (ideally as close to 100% as possible!)
  • Appropriate assertions are in the tests to verify the logic is working as expected (getting the coverage is easy, ensuring the right assertions to correctly test the logic is the hard part!)
  • Where appropriate, code has been refactored to be more modular, readable and testable (ideally, do this after writing the tests for that functionality to ensure no breaking changes)
  • All code branches of functional code execution have coverage and assertions to ensure functional changes will trigger a failing test
  • Another team member has reviewed
  • Tests are green
@connormaglynn connormaglynn added needs refining go Pull requests that update Go code technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. testing code quality labels Apr 3, 2024
@connormaglynn connormaglynn changed the title 🧪 Improve Quality and Coverage of Unit Test in modernisation-platform-instance-schedular 🧪 Improve Quality and Coverage of Unit Tests in modernisation-platform-instance-schedular Apr 3, 2024
@dms1981 dms1981 changed the title 🧪 Improve Quality and Coverage of Unit Tests in modernisation-platform-instance-schedular 🧪 Improve Quality and Coverage of Unit Tests in modernisation-platform-instance-scheduler May 9, 2024
@connormaglynn connormaglynn self-assigned this May 20, 2024
@connormaglynn
Copy link
Contributor Author

🆙 Update

👀 Remaining Work

  • Need to remove all logic of checking whether the action is stop, start or stop in ec2.go and rds.go and have this at the top level (in the handler) - this will aid in the ease of unit testing by lowering the amount of responsibility each function has
  • Need to add more unit test coverage to the main.go file. This requires its dependencies to be injectable, which this PR sets up the start of a framework for

📝 Notes

  • NA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality go Pull requests that update Go code technical debt This issue is either technical debt or an issue that will lead to technical debt as time goes by. testing
Projects
Status: In Progress
Development

No branches or pull requests

3 participants