Skip to content

Commit

Permalink
Fix tests by making testInvoke async
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Jul 2, 2024
1 parent 34f4f17 commit 3d0fd29
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Tests/D2CommandTests/Misc/EchoCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import D2TestUtils
@testable import D2Commands

final class EchoCommandTests: XCTestCase {
func testInvocation() throws {
func testInvocation() async throws {
let command = EchoCommand()
let output = TestOutput()

command.testInvoke(with: .text("demo"), output: output)
await command.testInvoke(with: .text("demo"), output: output)
XCTAssertEqual(output.lastContent, "demo")
}
}
10 changes: 5 additions & 5 deletions Tests/D2CommandTests/Music/FindKeyCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import D2TestUtils
@testable import D2Commands

final class FindKeyCommandTests: XCTestCase {
func testFindKey() throws {
func testFindKey() async throws {
let command = FindKeyCommand()
let output = TestOutput()

command.testInvoke(with: .text("C"), output: output)
await command.testInvoke(with: .text("C"), output: output)
XCTAssertEqual(output.lastContent, "Possible keys: C Cm Db Dm Eb Em F Fm G Gm Ab Am Bb Bbm")

command.testInvoke(with: .text("E Eb"), output: output)
await command.testInvoke(with: .text("E Eb"), output: output)
XCTAssertEqual(output.lastContent, "Possible keys: ")

command.testInvoke(with: .text("C Db E"), output: output)
await command.testInvoke(with: .text("C Db E"), output: output)
XCTAssertEqual(output.lastContent, "Possible keys: ")

command.testInvoke(with: .text("C Db Eb"), output: output)
await command.testInvoke(with: .text("C Db Eb"), output: output)
XCTAssertEqual(output.lastContent, "Possible keys: Db Fm Ab Bbm")
}
}
4 changes: 2 additions & 2 deletions Tests/D2TestUtils/CommandTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ extension Command {
with input: RichValue = .none,
output: any CommandOutput,
context: CommandContext = CommandContext(sink: nil, registry: CommandRegistry(), message: Message(content: ""), commandPrefix: "", subscriptions: SubscriptionSet())
) {
invoke(with: input, output: output, context: context)
) async {
await invoke(with: input, output: output, context: context)
}

public func testSubscriptionMessage(
Expand Down

0 comments on commit 3d0fd29

Please sign in to comment.