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

Move to using interface for better mocking at chaoshub package #3933

Merged
merged 4 commits into from
Mar 29, 2023

Conversation

namkyu1999
Copy link
Member

@namkyu1999 namkyu1999 commented Mar 25, 2023

Proposed changes

Currently, our Golang codebase heavily relies on concrete types for implementing functionality. It causes hard to make unit tests. So I propose an interface pattern for loose coupling like this PR. For this PR, I only targeted the chaoshub package. If this approach is correct. I will refactor all packages to the interface.

And last, The below variable will be deleted after all packages are refactored to the interface.

Operator MongoOperator = &MongoOperations{}

Issue No. #3931 #3892

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

  • Please add the links to the dependent PR need to be merged before this (if any).

Special notes for your reviewer: @S-ayanide @amityt

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
@S-ayanide S-ayanide added the LFX-MENTORSHIP Linux Foundation Mentor ship Issue label Mar 26, 2023
Copy link
Member

@S-ayanide S-ayanide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean code 🚀 Hub looks pretty refactored to me 🏆

@S-ayanide S-ayanide requested a review from amityt March 26, 2023 11:45
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Copy link
Member

@gdsoumya gdsoumya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, rest looks good

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
@namkyu1999 namkyu1999 requested review from amityt and gdsoumya and removed request for amityt and gdsoumya March 27, 2023 10:08
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Copy link
Member

@gdsoumya gdsoumya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the PR!

@namkyu1999 namkyu1999 requested a review from amityt March 28, 2023 00:46
@imrajdas imrajdas merged commit 118ba8f into litmuschaos:master Mar 29, 2023
namkyu1999 added a commit to namkyu1999/litmus that referenced this pull request Apr 7, 2023
…schaos#3933)

* fix: Move to using interface for better mocking at chaoshub

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: delete operator interface and linting codes

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: change db instance to local variable

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: passing operator interface for better mocking

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

---------

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
imrajdas pushed a commit that referenced this pull request Apr 7, 2023
* Migrate from Gorilla mux to Gin

Signed-off-by: Namkyu Park <lak9348@gmail.com>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* Linting & Ordering codes

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: remove duplicated code

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: adopt go fmt

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* Move to using interface for better mocking at chaoshub package (#3933)

* fix: Move to using interface for better mocking at chaoshub

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: delete operator interface and linting codes

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: change db instance to local variable

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: passing operator interface for better mocking

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

---------

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: status code to constant variable

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: add logs when encounterd error

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: rename pkg name

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: rename pkg, graphql_server to rest_handlers

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: resolve codeql issue

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

* fix: add replacer value

Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>

---------

Signed-off-by: Namkyu Park <lak9348@gmail.com>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LFX-MENTORSHIP Linux Foundation Mentor ship Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants