Skip to content

Commit

Permalink
DotEnvTest: all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg3lopez committed Oct 25, 2023
1 parent 4696577 commit 3549878
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@ package gov.hhs.cdc.trustedintermediary.context
import io.github.cdimascio.dotenv.Dotenv
import spock.lang.Specification

import java.lang.reflect.Field

class DotEnvTest extends Specification {

def "get method should return value for existing key"() {
given:
def mockDotenv = Mock(Dotenv)
mockDotenv.get("test_id") >> "test_value"

DotEnv.load(mockDotenv)

when:
String value = DotEnv.get("test_id")

then:
1==1
value == "test_value"
}

def "get method should return null for non-existent key"() {
given:
def dotenv = Mock(Dotenv)
dotenv.get("nonexistent_key") >> null
def mockDotenv = Mock(Dotenv)
mockDotenv.get("nonexistent_key") >> null
DotEnv.load(mockDotenv)

when:
String value = DotEnv.get("nonexistent_key")
Expand All @@ -35,8 +34,9 @@ class DotEnvTest extends Specification {

def "get method with default value should return value for existing key"() {
given:
Dotenv dotenv = Mock(Dotenv)
dotenv.get("test_key", "default_value") >> "test_value"
def mockDotenv = Mock(Dotenv)
mockDotenv.get("test_key", "default_value") >> "test_value"
DotEnv.load(mockDotenv)

when:
String value = DotEnv.get("test_key", "default_value")
Expand All @@ -47,8 +47,9 @@ class DotEnvTest extends Specification {

def "get method with default value should return default value for non-existent key"() {
given:
Dotenv dotenv = Mock(Dotenv)
dotenv.get("nonexistent_key", "default_value") >> "default_value"
def mockDotenv = Mock(Dotenv)
mockDotenv.get("nonexistent_key", "default_value") >> "default_value"
DotEnv.load(mockDotenv)

when:
String value = DotEnv.get("nonexistent_key", "default_value")
Expand Down

0 comments on commit 3549878

Please sign in to comment.