This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 15c681724 Core: Update TestEnvironmentUtil for environments with no 
USER (#5353)
15c681724 is described below

commit 15c6817247968328c2bab2af71616ce3f2209d31
Author: Steven Zhen Wu <[email protected]>
AuthorDate: Fri Jul 29 14:17:21 2022 -0700

    Core: Update TestEnvironmentUtil for environments with no USER (#5353)
---
 .../org/apache/iceberg/util/TestEnvironmentUtil.java  | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git 
a/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java 
b/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
index d7fb17b0e..dcfcfe463 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
@@ -26,10 +26,21 @@ import org.junit.jupiter.api.Test;
 class TestEnvironmentUtil {
   @Test
   public void testEnvironmentSubstitution() {
-    Assertions.assertEquals(
-        ImmutableMap.of("user-test", System.getenv().get("USER")),
-        EnvironmentUtil.resolveAll(ImmutableMap.of("user-test", "env:USER")),
-        "Should get the user from the environment");
+    String userFromEnv = System.getenv().get("USER");
+    Map<String, String> resolvedProps =
+        EnvironmentUtil.resolveAll(ImmutableMap.of("user-test", "env:USER"));
+    if (userFromEnv == null) {
+      // some build env may not have the USER env variable set
+      Assertions.assertEquals(
+          ImmutableMap.of(),
+          resolvedProps,
+          "Resolved properties should be empty if not exist from environment 
variables");
+    } else {
+      Assertions.assertEquals(
+          ImmutableMap.of("user-test", userFromEnv),
+          resolvedProps,
+          "Should get the user from the environment");
+    }
   }
 
   @Test

Reply via email to