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

🚨 test(VSecM Sentinel): 1100 add unit test and refactor app/sentinel #1129

Merged

Conversation

gurkanguray
Copy link
Contributor

Increase on Coverage ratio

Description

Added unit tests to app/sentinel/oidc/engine package and refactored the codebase

Changes

List the major changes you have made in bullet points:

  • Dependency injection on app/sentinel/oidc/engine
  • Added unit tests

Test Policy Compliance

  • I have added or updated unit tests for my changes.
  • I have included integration tests where applicable.
  • All new and existing tests pass successfully.

Code Quality

  • I have followed the coding standards for this project.
  • I have performed a self-review of my code.
  • My code is well-commented, particularly in areas that may be difficult
    to understand.

Documentation

  • I have made corresponding changes to the documentation (if applicable).
  • I have updated any relevant READMEs or wiki pages.

Additional Comments

Include any additional comments or context about the PR here.

Checklist

Before you submit this PR, please make sure:

  • You have read the contributing guidelines and
    especially the test policy.
  • You have thoroughly tested your changes.
  • You have followed all the contributing guidelines for this project.
  • You understand and agree that your contributions will be publicly available
    under the project's license.

By submitting this pull request, you confirm that my contribution is made under
the terms of the project's license and that you have the authority to grant
these rights.


Thank you for your contribution to VMware Secrets Manager
🐢⚡️!

added unit tests to app/sentinel/oidc/engine package and refactored the codebase

Signed-off-by: Guray Gurkan <[email protected]>
@gurkanguray gurkanguray changed the title 🚨 test(VSecM Sentinel): 1100 add unit test and refactor to sentinel 🚨 test(VSecM Sentinel): 1100 add unit test and refactor app/sentinel Sep 4, 2024
Comment on lines 39 to 42
safeOps := new(SafeClient)
logger := new(RpcLogger)

engine := engine.New(safeOps, logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

There’s nothing inherently wrong with using new in Go, but it’s less commonly used in idiomatic Go code because of how it behaves compared to other memory allocation patterns in Go. The new function allocates memory but doesn't initialize the object beyond setting it to its zero value.

This is in contrast to using a constructor-like approach (which can include more complex initialization logic).

Consider using safeOps := &SafeClient{}

Or if you feel Java…ey, using a custom constructor function:

func NewSafeClient() *SafeClient {
    return &SafeClient{
        // Initialize necessary fields here
    }
}

safeOps := NewSafeClient()

Also, if you don't need a pointer to the struct, you can simply assign it directly:

safeOps := SafeClient{}
logger := RpcLogger{}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, let me make it more goish not javaish :)

new() usage replaced with &

Signed-off-by: Guray Gurkan <[email protected]>
replaced new() with more idiomatic approach using &

Signed-off-by: Guray Gurkan <[email protected]>
@v0lkan
Copy link
Contributor

v0lkan commented Sep 5, 2024

update: there is a minor test failure in the integration server.

@gurkanguray and I are investigating it.

Once we fix the issue; unless anyone disagrees, we can merge this.

Thanks for your contributions @gurkanguray .

unit test fixing relating to the interface conversion

Signed-off-by: Guray Gurkan <[email protected]>
@gurkanguray
Copy link
Contributor Author

Thank you @v0lkan, I believe I've fixed the issue. Ready for testing again 👍🏻

@v0lkan v0lkan merged commit 187ca6e into vmware-tanzu:main Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants