Skip to content

Commit

Permalink
Merge pull request #19 from SwiftPackageIndex/hang-workaround
Browse files Browse the repository at this point in the history
Hang workaround
  • Loading branch information
finestructure committed Mar 28, 2024
2 parents 4877d48 + c77015f commit a335f12
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
7 changes: 2 additions & 5 deletions Sources/DocUploadBundle/DocUploadBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@

import Foundation

#if swift(>=5.6)
// Swift5.5Tests need to run with Swift 5.5 but swift-dependencies has tools-version 5.6
import Dependencies
#endif
import Zip


public struct DocUploadBundle {

#if swift(>=5.6)
// Swift5.5Tests need to run with Swift 5.5 but swift-dependencies has tools-version 5.6
// Workaround for https://github.com/pointfreeco/swift-dependencies/issues/199
#if DEBUG
@Dependency(\.uuid) var uuid
#else
let uuid = { UUID() }
Expand Down
11 changes: 1 addition & 10 deletions Sources/DocUploader/Dependencies/HTTPExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,5 @@ extension HTTPExecutor {
}

extension HTTPExecutor: DependencyKey {
static var liveValue: HTTPExecutor {
.live
}
}

extension DependencyValues {
var httpClient: HTTPExecutor {
get { self[HTTPExecutor.self] }
set { self[HTTPExecutor.self] = newValue }
}
static var liveValue: HTTPExecutor { .live }
}
7 changes: 6 additions & 1 deletion Sources/DocUploader/DocReport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import NIOHTTP1

enum DocReport {

@Dependency(\.httpClient) static var httpClient: HTTPExecutor
// Workaround for https://github.com/pointfreeco/swift-dependencies/issues/199
#if DEBUG
@Dependency(HTTPExecutor.self) static var httpClient: HTTPExecutor
#else
static let httpClient: HTTPExecutor = .live
#endif

enum Status: String, Codable {
case ok
Expand Down
2 changes: 1 addition & 1 deletion Tests/DocUploaderTests/DocUploaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class DocUploaderTests: XCTestCase {
func test_reportResult() async throws {
var request: HTTPClientRequest?
try await withDependencies {
$0.httpClient.execute = { _, req, _ in
$0[HTTPExecutor.self].execute = { _, req, _ in
request = req
return .init(status: .noContent)
}
Expand Down

0 comments on commit a335f12

Please sign in to comment.