You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2022/10/12 15:38:39 UTC
[iceberg] branch master updated: Core: Make testEnvironmentSubstitution effective when USER is not set (#5770)
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 f848da0a59 Core: Make testEnvironmentSubstitution effective when USER is not set (#5770)
f848da0a59 is described below
commit f848da0a59e51141084e06ce32d5d4739e882711
Author: Dmitri Bourlatchkov <dm...@dremio.com>
AuthorDate: Wed Oct 12 11:38:31 2022 -0400
Core: Make testEnvironmentSubstitution effective when USER is not set (#5770)
---
.../apache/iceberg/util/TestEnvironmentUtil.java | 24 +++++++++-------------
1 file changed, 10 insertions(+), 14 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 dcfcfe4635..7fdb93edde 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
@@ -19,28 +19,24 @@
package org.apache.iceberg.util;
import java.util.Map;
+import java.util.Optional;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
class TestEnvironmentUtil {
@Test
public void testEnvironmentSubstitution() {
- String userFromEnv = System.getenv().get("USER");
+ Optional<Map.Entry<String, String>> envEntry = System.getenv().entrySet().stream().findFirst();
+ Assumptions.assumeTrue(
+ envEntry.isPresent(), "Expecting at least one env. variable to be present");
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");
- }
+ EnvironmentUtil.resolveAll(ImmutableMap.of("env-test", "env:" + envEntry.get().getKey()));
+ Assertions.assertEquals(
+ ImmutableMap.of("env-test", envEntry.get().getValue()),
+ resolvedProps,
+ "Should get the user from the environment");
}
@Test