Few fixes and improvements to the library, plus Github Actions setup (#31)
CI / Build and test (push) Canceled after 0s
Documentation / Build documentation (push) Canceled after 0s
Documentation / Deploy to GitHub Pages (push) Canceled after 0s

This PR contains the work done to fix a cancellation-mapping bug in `AmiiboLiveClient`, bring the client under offline test coverage, add the conformances SwiftUI and persistence need, and moves CI and documentation publishing to GitHub Actions. All public API changes are additive.

### Fix

- `AmiiboLiveClient` reported an early task cancellation as `.unknown("CancellationError()")`. The OpenAPI runtime wraps every error in `ClientError`, so the `CancellationError` check never matched; it now also checks the wrapped error and throws `.cancelled`.

### Tests

- `ThrowingTransport` and `StubTransport` test doubles let the live client run offline. New tests cover error mapping, HTTP status → error mapping, `oneOf` object-vs-list decoding, `"amiibo": null`, sorting, filter → query encoding, `Platform`/`Release` mapping, and the date transcoder.
- Models gained `package` memberwise initializers so tests can build real fixtures without `@testable`. These are not public API.
- The test target now depends on `OpenAPIRuntime` and `HTTPTypes` (both already in the dependency graph).

### API
- Models are `Codable` and `Identifiable` (`Amiibo.id` is its `identifier`; the key/name models use `key`).
- Filters are `Hashable`.

### Documentation
- Doc comments trimmed library-wide; one repeated `- Throws:` sentence appeared 24 times. `Library.md` and the README tightened to match.

### CI and docs publishing
- `ci.yml`: build and offline tests on PRs and pushes to `main`.
- `live-tests.yml`: weekly and on-demand run against the live API.
- `docs.yml`: builds DocC on PRs, deploys to GitHub Pages on `main`. Pinned to Xcode 26 because swift-docc-plugin 1.5.0 fails to launch its tools under Xcode 27.
- The generated `docs/` folder (327 files) is removed from the repository and ignored.

Reviewed-on: #31
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #31.
This commit is contained in:
javier authored and Javier Cicchelli committed 2026-10-25 19:54:30 +00:00
1 parent 44bfaca553
commit 13b9c74a38
361 files changed
+1395 -863

No files matched your search

@@ -32,7 +32,21 @@ struct AmiiboServiceMockTests {
// THEN
#expect(amiibos.isEmpty)
}
@Test("returns amiibos when mock provides a list")
func getAmiibosList() async throws {
// GIVEN
let service = AmiiboService(client: AmiiboMockClient(amiibos: Fixtures.amiibos))
// WHEN
let amiibos = try await service.getAmiibos()
// THEN
#expect(amiibos == Fixtures.amiibos)
#expect(amiibos.first?.identifier == "0100000000040002")
#expect(amiibos.first?.imageURL != nil)
}
@Test("throws notFound when mock provides no amiibos")
func getAmiibosNotFound() async {
// GIVEN
@@ -70,7 +84,19 @@ struct AmiiboServiceMockTests {
// THEN
#expect(amiiboSeries.isEmpty)
}
@Test("returns amiibo series when mock provides a list")
func getAmiiboSeriesList() async throws {
// GIVEN
let service = AmiiboService(client: AmiiboMockClient(amiiboSeries: Fixtures.amiiboSeries))
// WHEN
let amiiboSeries = try await service.getAmiiboSeries()
// THEN
#expect(amiiboSeries == Fixtures.amiiboSeries)
}
@Test("throws notFound when mock provides no amiibo series")
func getAmiiboSeriesNotFound() async {
// GIVEN
@@ -108,7 +134,19 @@ struct AmiiboServiceMockTests {
// THEN
#expect(amiiboTypes.isEmpty)
}
@Test("returns amiibo types when mock provides a list")
func getAmiiboTypesList() async throws {
// GIVEN
let service = AmiiboService(client: AmiiboMockClient(amiiboTypes: Fixtures.amiiboTypes))
// WHEN
let amiiboTypes = try await service.getAmiiboTypes()
// THEN
#expect(amiiboTypes == Fixtures.amiiboTypes)
}
@Test("throws notFound when mock provides no amiibo types")
func getAmiiboTypesNotFound() async {
// GIVEN
@@ -146,7 +184,19 @@ struct AmiiboServiceMockTests {
// THEN
#expect(gameCharacters.isEmpty)
}
@Test("returns game characters when mock provides a list")
func getGameCharactersList() async throws {
// GIVEN
let service = AmiiboService(client: AmiiboMockClient(gameCharacters: Fixtures.gameCharacters))
// WHEN
let gameCharacters = try await service.getGameCharacters()
// THEN
#expect(gameCharacters == Fixtures.gameCharacters)
}
@Test("throws notFound when mock provides no game characters")
func getGameCharactersNotFound() async {
// GIVEN
@@ -184,7 +234,19 @@ struct AmiiboServiceMockTests {
// THEN
#expect(gameSeries.isEmpty)
}
@Test("returns game series when mock provides a list")
func getGameSeriesList() async throws {
// GIVEN
let service = AmiiboService(client: AmiiboMockClient(gameSeries: Fixtures.gameSeries))
// WHEN
let gameSeries = try await service.getGameSeries()
// THEN
#expect(gameSeries == Fixtures.gameSeries)
}
@Test("throws notFound when mock provides no game series")
func getGameSeriesNotFound() async {
// GIVEN