Skip to content

Commit

Permalink
withLock { $0 } → withLock(\.self)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyome22 committed Jan 18, 2025
1 parent d16e5c0 commit b7cdf6f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class LoggerServiceTests: XCTestCase {
let sut = LogService(loggingSystemClient)
await sut.bootstrap()
await sut.bootstrap()
let actual = count.withLock { $0 }
let actual = count.withLock(\.self)
XCTAssertEqual(actual, 1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class ShortcutServiceTests: XCTestCase {
}
let sut = ShortcutService(spiceKeyClient, userDefaultsClient, .testValue)
await sut.initializeShortcuts()
let actual = count.withLock { $0 }
let actual = count.withLock(\.self)
XCTAssertEqual(actual, 1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ final class GeneralSettingsViewModelTests: XCTestCase {
}
let sut = GeneralSettingsViewModel(nsWorkspaceClient, .testValue, .testValue, .init(.testValue))
sut.openSystemSettings()
let actual = calledURLs.withLock { $0 }
let actual = calledURLs.withLock(\.self)
XCTAssertEqual(actual, [URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")!])
}

@MainActor
func test_launchAtLoginSwitched_有効の要求_成功した_有効に変更される() async {
let currentStatus = OSAllocatedUnfairLock(initialState: SMAppService.Status.notRegistered)
let smAppServiceClient = testDependency(of: SMAppServiceClient.self) {
$0.status = { currentStatus.withLock { $0 } }
$0.status = { currentStatus.withLock(\.self) }
$0.register = { currentStatus.withLock { $0 = .enabled } }
}
let sut = GeneralSettingsViewModel(.testValue, .testValue, smAppServiceClient, .init(.testValue))
Expand All @@ -49,7 +49,7 @@ final class GeneralSettingsViewModelTests: XCTestCase {
func test_launchAtLoginSwitched_無効の要求_成功した_無効に変更される() async {
let currentStatus = OSAllocatedUnfairLock(initialState: SMAppService.Status.enabled)
let smAppServiceClient = testDependency(of: SMAppServiceClient.self) {
$0.status = { currentStatus.withLock { $0 } }
$0.status = { currentStatus.withLock(\.self) }
$0.unregister = { currentStatus.withLock { $0 = .notRegistered } }
}
let sut = GeneralSettingsViewModel(.testValue, .testValue, smAppServiceClient, .init(.testValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class MenuViewModelTests: XCTestCase {
.init(.testValue)
)
sut.activateApp()
XCTAssertEqual(count.withLock { $0 }, 1)
XCTAssertEqual(count.withLock(\.self), 1)
}

@MainActor
Expand All @@ -39,7 +39,7 @@ final class MenuViewModelTests: XCTestCase {
.init(spuUpdaterClient)
)
await sut.checkForUpdates()
XCTAssertEqual(count.withLock { $0 }, 1)
XCTAssertEqual(count.withLock(\.self), 1)
}

@MainActor
Expand All @@ -60,7 +60,7 @@ final class MenuViewModelTests: XCTestCase {
.init(.testValue)
)
sut.openAbout()
XCTAssertEqual(callStack.withLock { $0 }, [
XCTAssertEqual(callStack.withLock(\.self), [
"activate",
"orderFrontStandardAboutPanel",
])
Expand All @@ -81,6 +81,6 @@ final class MenuViewModelTests: XCTestCase {
.init(.testValue)
)
sut.terminateApp()
XCTAssertEqual(count.withLock { $0 }, 1)
XCTAssertEqual(count.withLock(\.self), 1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ final class ShortcutSettingsViewModelTests: XCTestCase {
}
let sut = ShortcutSettingsViewModel(.testValue, .init(.testValue), .init(spiceKeyClient, userDefaultsClient, .testValue))
await sut.updateKeyCombination(pattern: .init(shiftType: .topHalf), keyCombo: .init(.b, .cmd))
XCTAssertEqual(registerCount.withLock { $0 }, 1)
XCTAssertEqual(setDataCount.withLock { $0 }, 1)
XCTAssertEqual(registerCount.withLock(\.self), 1)
XCTAssertEqual(setDataCount.withLock(\.self), 1)
}

@MainActor
Expand All @@ -48,6 +48,6 @@ final class ShortcutSettingsViewModelTests: XCTestCase {
}
let sut = ShortcutSettingsViewModel(.testValue, .init(.testValue), .init(.testValue, userDefaultsClient, .testValue))
await sut.updateKeyCombination(pattern: .init(shiftType: .topHalf), keyCombo: nil)
XCTAssertEqual(setDataCount.withLock { $0 }, 1)
XCTAssertEqual(setDataCount.withLock(\.self), 1)
}
}

0 comments on commit b7cdf6f

Please sign in to comment.