Skip to content

Commit a8be69a

Browse files
committed
Fix test failure upstream
Test fails on GitHub CI due to an absence of GoogleCredentials in the environment.
1 parent f61f932 commit a8be69a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gcp-auth-extension/src/test/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProviderTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,16 @@ public void testCustomizerOtlpGrpc() {
201201
@Test
202202
public void testCustomizerFailWithMissingResourceProject() {
203203
OtlpGrpcSpanExporter mockOtlpGrpcSpanExporter = Mockito.mock(OtlpGrpcSpanExporter.class);
204-
assertThrows(
205-
ConfigurationException.class,
206-
() -> buildOpenTelemetrySdkWithExporter(mockOtlpGrpcSpanExporter));
204+
try (MockedStatic<GoogleCredentials> googleCredentialsMockedStatic =
205+
Mockito.mockStatic(GoogleCredentials.class)) {
206+
googleCredentialsMockedStatic
207+
.when(GoogleCredentials::getApplicationDefault)
208+
.thenReturn(mockedGoogleCredentials);
209+
210+
assertThrows(
211+
ConfigurationException.class,
212+
() -> buildOpenTelemetrySdkWithExporter(mockOtlpGrpcSpanExporter));
213+
}
207214
}
208215

209216
@SuppressWarnings("CannotMockMethod")

0 commit comments

Comments
 (0)