Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ncipollo committed Oct 17, 2024
1 parent 140112c commit 14f0ede
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Sources/WhoopDIKit/Container/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class Container {
public func inject<T>(_ name: String? = nil,
params: Any? = nil,
_ localDefinition: (DependencyModule) -> Void) -> T {
return localDependencyGraph.aquireDependencyGraph { localServiceDict in
return localDependencyGraph.acquireDependencyGraph { localServiceDict in
// Nested local injects are not currently supported. Fail fast here.
guard !isLocalInjectActive else {
fatalError("Nesting WhoopDI.inject with local definitions is not currently supported")
Expand Down Expand Up @@ -113,7 +113,7 @@ public final class Container {
}

private func getDefinition(_ serviceKey: ServiceKey) -> DependencyDefinition? {
localDependencyGraph.aquireDependencyGraph { localServiceDict in
localDependencyGraph.acquireDependencyGraph { localServiceDict in
return localServiceDict[serviceKey] ?? serviceDict[serviceKey]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class ThreadSafeDependencyGraph: Sendable {
self.options = options
}

func aquireDependencyGraph<T>(block: (ServiceDictionary<DependencyDefinition>) -> T) -> T {
func acquireDependencyGraph<T>(block: (ServiceDictionary<DependencyDefinition>) -> T) -> T {
let threadSafe = options.isOptionEnabled(.threadSafeLocalInject)
if threadSafe {
lock.lock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import Testing

struct ThreadSafeDependencyGraphTests {
@Test(arguments: [false, true])
func aquireDependencyGraph_notThreadSafe(threadsafe: Bool) {
func acquireDependencyGraph_notThreadSafe(threadsafe: Bool) {
let options = MockOptionProvider(options: [.threadSafeLocalInject: threadsafe])
let graph = ThreadSafeDependencyGraph(options: options)

graph.aquireDependencyGraph { serviceDict in
graph.acquireDependencyGraph { serviceDict in
serviceDict[DependencyA.self] = FactoryDefinition(name: nil) { _ in DependencyA() }
}
graph.aquireDependencyGraph { serviceDict in
graph.acquireDependencyGraph { serviceDict in
let dependency = serviceDict[DependencyA.self]
#expect(dependency != nil)
}

graph.resetDependencyGraph()

graph.aquireDependencyGraph { serviceDict in
graph.acquireDependencyGraph { serviceDict in
let dependency = serviceDict[DependencyA.self]
#expect(dependency == nil)
}
}

@Test
func aquireDependencyGraph_recursive() {
func acquireDependencyGraph_recursive() {
let options = MockOptionProvider(options: [.threadSafeLocalInject: true])
let graph = ThreadSafeDependencyGraph(options: options)

graph.aquireDependencyGraph { outer in
graph.aquireDependencyGraph { serviceDict in
graph.acquireDependencyGraph { outer in
graph.acquireDependencyGraph { serviceDict in
serviceDict[DependencyA.self] = FactoryDefinition(name: nil) { _ in DependencyA() }
}
let dependency = outer[DependencyA.self]
Expand Down

0 comments on commit 14f0ede

Please sign in to comment.