mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Throw error when envvar is missing and provide unit tests
This commit is contained in:
parent
fca6971316
commit
1ff76aebd4
@ -573,6 +573,9 @@
|
||||
</includes>
|
||||
<useSystemClassLoader>false
|
||||
</useSystemClassLoader> <!-- fixes reflection tests -->
|
||||
<environmentVariables>
|
||||
<TEST_ENV_VAR>value</TEST_ENV_VAR>
|
||||
</environmentVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
@ -169,8 +169,9 @@ public class NBAtFile {
|
||||
String word = iter.next();
|
||||
String modified = word.replaceAll("\\$\\{DIR}",parent.toString());
|
||||
Optional<String> interpolatedString = NBEnvironment.INSTANCE.interpolate(modified);
|
||||
String value = interpolatedString.orElseThrow(() -> new RuntimeException("Unable to find environment variable or property in text '"+modified+"' in atfile '" + atPath + "'"));
|
||||
iter.remove();
|
||||
iter.add(interpolatedString.orElse(""));
|
||||
iter.add(value);
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
@ -91,4 +91,15 @@ class NBAtFileTest {
|
||||
assertThat(strings).containsExactly("arg1","arg1","arg1","arg2","arg3","arg3","arg3","deepval");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtfileEnvironmentVariable() {
|
||||
LinkedList<String> strings = NBAtFile.includeAt("@src/test/resources/atfiles/environment_variable.yaml");
|
||||
assertThat(strings).containsExactly("My value environment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtfileMissingEnvironmentVariable() {
|
||||
assertThrows(RuntimeException.class, () -> NBAtFile.includeAt("@src/test/resources/atfiles/environment_variable_missing.yaml:>:"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
- My ${MISSING_ENV_VAR} environment
|
@ -0,0 +1 @@
|
||||
- My ${TEST_ENV_VAR} environment
|
Loading…
Reference in New Issue
Block a user