Skip to content

Commit

Permalink
add multi-line test
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Apr 30, 2019
1 parent c12e00c commit 9d07969
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/test/java/tests/JavaTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public void iteratorOverDotenv() {
.ignoreIfMalformed()
.load();

Map<String,String> m = new HashMap<String, String>() {{
put("test", "hi");
put("test1", "hi1");
}};

dotenv.entries().forEach(e -> assertEquals(dotenv.get(e.getKey()), e.getValue()));

for (DotenvEntry e : dotenv.entries()) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/tests/BasicTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class DotEnvTest {
private val envVars = mapOf(
"MY_TEST_EV1" to "my test ev 1",
"MY_TEST_EV2" to "my test ev 2",
"WITHOUT_VALUE" to ""
"WITHOUT_VALUE" to "",
"MULTI_LINE" to "hello\\nworld"
)

@test(expected = DotEnvException::class)
Expand Down
12 changes: 11 additions & 1 deletion src/test/kotlin/tests/DslTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class DotEnvDslTest {
"MY_TEST_EV1" to "my test ev 1",
"MY_TEST_EV2" to "my test ev 2",
"WITHOUT_VALUE" to "",
"QUOTED_EV1" to "jdbc:hive2://[domain]:10000/default;principal=hive/_HOST@[REALM]"
"QUOTED_EV1" to "jdbc:hive2://[domain]:10000/default;principal=hive/_HOST@[REALM]",
"MULTI_LINE" to "hello\\nworld"
)

private val envVarsOverridenByHostEnv = mapOf(
Expand Down Expand Up @@ -108,6 +109,15 @@ class DotEnvDslTest {
}
}

@test
fun multiLine() {
val dotenv = Dotenv.configure()
.ignoreIfMalformed()
.load()

assertEquals(dotenv["MULTI_LINE"]!!, envVars["MULTI_LINE"]!!)
}

@test
fun resourceCurrent() {
val env = dotenv {
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
MY_TEST_EV1=my test ev 1
MY_TEST_EV2=my test ev 2
WITHOUT_VALUE=
MULTI_LINE=hello\nworld

## Malformed EV!
MY_TEST_EV3
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
MY_TEST_EV1=my test ev 1
MY_TEST_EV2=my test ev 2
WITHOUT_VALUE=
MULTI_LINE=hello\nworld

## Malformed EV!
MY_TEST_EV3

0 comments on commit 9d07969

Please sign in to comment.