Skip to content

Commit

Permalink
chore: Add env var test to github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 committed Feb 28, 2024
1 parent 09a7526 commit dba5631
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ jobs:
- name: Unit Tests
run: |
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=\!EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
- run: echo "GOOGLE_CLOUD_UNIVERSE_DOMAIN=random.com" >> $GITHUB_ENV
- name: EndpointContext Env Var Test
run: |
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
- run: bazelisk version
- name: Install Maven modules
run: |
Expand Down Expand Up @@ -63,7 +70,14 @@ jobs:
- name: Unit Tests
run: |
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=\!EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
- run: echo "GOOGLE_CLOUD_UNIVERSE_DOMAIN=random.com" >> $GITHUB_ENV
- name: EndpointContext Env Var Test
run: |
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
- run: bazelisk version
- name: Install Maven modules
run: |
Expand Down Expand Up @@ -97,7 +111,12 @@ jobs:
# the "jvm" system property.
mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip \
-Djvm="${JAVA8_HOME}/bin/java"
-Djvm="${JAVA8_HOME}/bin/java" -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=\!EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
export GOOGLE_CLOUD_UNIVERSE_DOMAIN=random.com
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
-Dtest=EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet
build-java8-gapic-generator-java:
name: "build(8) for gapic-generator-java"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,12 @@ public void endpointContextBuild_gdchFlow_noUniverseDomain_customEndpoint() thro
.isEqualTo(Credentials.GOOGLE_DEFAULT_UNIVERSE);
}

// JUnit has limitations with mocking Environment Variable. For this test, we simply replicate the
// behavior in `build()` by setting the universe domain to an env var value. Keeping this test
// case scenario if a future solution for testing env vars exists.
@Test
public void endpointContextBuild_universeDomainEnvVarSet() throws IOException {
String envVarUniverseDomain = "random.com";
EndpointContext endpointContext =
defaultEndpointContextBuilder
.setUniverseDomain(envVarUniverseDomain)
.setUniverseDomain(null)
.setClientSettingsEndpoint(null)
.build();
Truth.assertThat(endpointContext.resolvedEndpoint()).isEqualTo("test.random.com:443");
Expand Down

0 comments on commit dba5631

Please sign in to comment.