Skip to content

Commit

Permalink
create dotenv java tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Jan 1, 2018
1 parent bbbd286 commit 0cc0342
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/test/java/tests/JavaTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package tests;

import io.github.cdimascio.dotenv.DotEnvException;
import io.github.cdimascio.dotenv.Dotenv;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class JavaTests {
@Test(expected = DotEnvException.class)
public void throwIfMalconfigured() {
Dotenv.configure().load();
}

@Test(expected = DotEnvException.class)
public void load() {
Dotenv dotenv = Dotenv.load();
assertEquals("my test ev 1", dotenv.get("MY_TEST_EV1"));
}

@Test
public void configurWithIgnoreMalformed() {
Dotenv dotenv = Dotenv.configure()
.ignoreIfMalformed()
.load();
assertEquals("my test ev 1", dotenv.get("MY_TEST_EV1"));
}

@Test
public void configurWithIgnoreMissingAndMalformed() {
Dotenv dotenv = Dotenv.configure()
.directory("/missing/dir")
.ignoreIfMalformed()
.ignoreIfMissing()
.load();
assertNotNull(dotenv.get("HOME"));
}
}

0 comments on commit 0cc0342

Please sign in to comment.