Clean up empty tests and migrate GemAPI test suite#1829
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the project's testing infrastructure by removing unused and empty test files and upgrading the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request migrates several test files and their corresponding package configurations from XCTest to the swift-testing framework. This involved updating test class definitions, replacing XCTAssert assertions with #expect, and adapting error handling mechanisms. The review comments suggest further idiomatic improvements for error testing within the swift-testing framework, specifically recommending the use of #expect(throws:) for both synchronous and asynchronous error scenarios to enhance conciseness and clarity.
| do { | ||
| _ = try DeviceRequestSigner(privateKeyHex: "not_valid_hex") | ||
| Issue.record("Expected invalid hex to throw") | ||
| } catch {} |
There was a problem hiding this comment.
While this do-catch block works, swift-testing provides a more idiomatic way to test for thrown errors using #expect(throws:). This makes the test more concise and clearly states the intent. The DeviceRequestSigner initializer is expected to throw an AnyError for invalid hex input.
#expect(throws: AnyError.self) {
_ = try DeviceRequestSigner(privateKeyHex: "not_valid_hex")
}| do { | ||
| _ = try await service.getDeviceAssets(walletId: "wallet", fromTimestamp: 0) | ||
| Issue.record("Expected preflight to throw") | ||
| } catch { | ||
| #expect(events.snapshot().isEmpty) | ||
| } |
There was a problem hiding this comment.
Since this is an async test, you can use await #expect(throws:) to make the error handling more concise and idiomatic to swift-testing. This also makes the test's intent clearer.
await #expect(throws: TestError.self) {
_ = try await service.getDeviceAssets(walletId: "wallet", fromTimestamp: 0)
}
#expect(events.snapshot().isEmpty)
No description provided.