-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix(test): add mock method to mock credentials. #3312
Conversation
This reverts commit 75c51a9.
return () -> mock(Credentials.class); | ||
Credentials mockCredential = mock(Credentials.class); | ||
when(mockCredential.getMetricsCredentialType()) | ||
.thenReturn(CredentialTypeForMetrics.DO_NOT_SEND); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If mock credentials were placed in core, could you avoid the duplication here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock credentials are placed under "test" folder, not accessible here.
spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/TestUtils.java
Created another util class in this module to avoid duplicating logic.
import com.google.auth.Credentials; | ||
|
||
public class TestUtils { | ||
public static final Credentials MOCK_CREDENTIALS = createMockCredentials(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, this is needed from classes in sub-packages within com.google.cloud.spring.autoconfigure
.
Quality Gate passedIssues Measures |
This change is to avoid runtime error when creating the client bean #3307 (comment)
Adding a mock return for
getMetricsCredentialType()
because in gax we do not allow for null values (should not happen because default is set)Also added together in this pr so ci could pass:
BEGIN_COMMIT_OVERRIDE
fix(deps): update dependency com.google.cloud:libraries-bom to v26.49.0
fix(test): add mock method to mock credentials.
END_COMMIT_OVERRIDE