Skip to content

Commit

Permalink
Add fatal error on missing EnvironmentVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
drhaynes authored and dhardiman committed Jan 22, 2024
1 parent 028f52a commit 47b0a31
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/Config/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ enum PropertyType: String {
guard let environmentVariable = value as? String,
let rawValue = getenv(environmentVariable),
let stringValue = String(utf8String: rawValue) else {
return "\"\""
fatalError("Missing environment variable \(value)")
}
return "#\"\(stringValue)\"#"
default:
Expand Down
7 changes: 0 additions & 7 deletions Tests/ConfigTests/ConfigurationPropertyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,6 @@ class ConfigurationPropertyTests: XCTestCase {
expect(actualValue).to(equal(expectedValue))
}

func testItWritesAnEmptyStringForAnEnvironmentVariableThatIsNotSet() throws {
let property = ConfigurationProperty<String>(key: "test", typeHint: "EnvironmentVariable", dict: ["defaultValue": "DOESNT_EXIST"])
let expectedValue = ##" static let test: String = """##
let actualValue = try whenTheDeclarationIsWritten(for: property)
expect(actualValue).to(equal(expectedValue))
}

func testItCanUseCommonPatternsForOverrides() throws {
let dict: [String: Any] = [
"defaultValue": "test value",
Expand Down

0 comments on commit 47b0a31

Please sign in to comment.