-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from juri/export
Add export method for overriding environment
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@testable import DotEnvy | ||
import XCTest | ||
|
||
final class ExportTests: XCTestCase { | ||
func testOverwrite() throws { | ||
setenv("KEY1", "ENVVALUE1", 1) | ||
let dotenv = try DotEnvironment.make( | ||
source: """ | ||
KEY1=DOTENVVALUE1 | ||
KEY2=DOTENVVALUE2 | ||
""", | ||
overrides: .none | ||
) | ||
dotenv.export(overwrite: true) | ||
XCTAssertEqual(ProcessInfo.processInfo.environment["KEY1"], "DOTENVVALUE1") | ||
XCTAssertEqual(ProcessInfo.processInfo.environment["KEY2"], "DOTENVVALUE2") | ||
} | ||
|
||
func testNoOverwrite() throws { | ||
setenv("KEY1", "ENVVALUE1", 1) | ||
let dotenv = try DotEnvironment.make( | ||
source: """ | ||
KEY1=DOTENVVALUE1 | ||
KEY2=DOTENVVALUE2 | ||
""", | ||
overrides: .none | ||
) | ||
dotenv.export(overwrite: false) | ||
XCTAssertEqual(ProcessInfo.processInfo.environment["KEY1"], "ENVVALUE1") | ||
XCTAssertEqual(ProcessInfo.processInfo.environment["KEY2"], "DOTENVVALUE2") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters