Skip to content

Commit

Permalink
Merge pull request #11 from SwiftPackageIndex/environment-handling
Browse files Browse the repository at this point in the history
Add test_environment_isolation
  • Loading branch information
finestructure authored Oct 12, 2023
2 parents e862e88 + 7d5bd45 commit 8e609b6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Tests/ShellOutTests/ShellOutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ final class ShellOutTests: XCTestCase {
v0.1.0
""")
}

func test_environment_isolation() async throws {
setenv("TOKEN", "secret", 1)
defer { unsetenv("TOKEN") }

await XCTAssertEqualAsync(
try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"],
environment: ProcessInfo.processInfo.environment).stdout, "secret"
)
await XCTAssertEqualAsync(
try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"],
environment: [:]).stdout, ""
)
}
}

extension ShellOutTests {
Expand Down

0 comments on commit 8e609b6

Please sign in to comment.