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
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:
1 parent
44bfaca553
commit
13b9c74a38
361 files changed
+1395
-863
No files matched your search
@@ -0,0 +1,85 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
//
|
||||
// This source file is part of the Amiibo Service open source project
|
||||
//
|
||||
// Copyright (c) 2026 Röck+Cöde VoF. and the Amiibo Service project authors
|
||||
// Licensed under Apache license v2.0
|
||||
//
|
||||
// See LICENSE for license information
|
||||
// See CONTRIBUTORS for the list of Amiibo Service project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
import AmiiboService
|
||||
import Foundation
|
||||
|
||||
/// Ready-made models for testing purposes.
|
||||
enum Fixtures {
|
||||
/// Amiibo items; the first one has release dates and related games with usages.
|
||||
static let amiibos: [Amiibo] = [
|
||||
.init(
|
||||
head: "01000000",
|
||||
tail: "00040002",
|
||||
name: "Zelda",
|
||||
type: "Figure",
|
||||
series: "Super Smash Bros.",
|
||||
gameCharacter: "Zelda",
|
||||
gameSeries: "The Legend of Zelda",
|
||||
image: "https://raw.githubusercontent.com/N3evin/AmiiboAPI/master/images/icon_01000000-00040002.png",
|
||||
release: .init(
|
||||
america: Date(timeIntervalSince1970: 1_416_441_600),
|
||||
australia: Date(timeIntervalSince1970: 1_417_564_800),
|
||||
europe: Date(timeIntervalSince1970: 1_417_132_800),
|
||||
japan: Date(timeIntervalSince1970: 1_417_564_800)
|
||||
),
|
||||
platform: .init(
|
||||
switch: [
|
||||
.init(
|
||||
identifiers: ["01007EF00011E000"],
|
||||
name: "The Legend of Zelda: Breath of the Wild",
|
||||
usages: [.init(explanation: "Spawns a random selection of items.", isWriteable: false)]
|
||||
)
|
||||
],
|
||||
wiiU: [
|
||||
.init(
|
||||
identifiers: ["0005000010145000"],
|
||||
name: "Super Smash Bros. for Wii U",
|
||||
usages: [.init(explanation: "Unlocks a figure player.", isWriteable: true)]
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
.init(
|
||||
head: "00000000",
|
||||
tail: "00000002",
|
||||
name: "Mario",
|
||||
type: "Figure",
|
||||
series: "Super Smash Bros.",
|
||||
gameCharacter: "Mario",
|
||||
gameSeries: "Super Mario",
|
||||
image: "https://raw.githubusercontent.com/N3evin/AmiiboAPI/master/images/icon_00000000-00000002.png"
|
||||
)
|
||||
]
|
||||
/// Amiibo series.
|
||||
static let amiiboSeries: [AmiiboSeries] = [
|
||||
.init(key: "0x00", name: "Super Smash Bros."),
|
||||
.init(key: "0x01", name: "Super Mario")
|
||||
]
|
||||
/// Amiibo types.
|
||||
static let amiiboTypes: [AmiiboType] = [
|
||||
.init(key: "0x00", name: "Figure"),
|
||||
.init(key: "0x01", name: "Card")
|
||||
]
|
||||
/// Game characters.
|
||||
static let gameCharacters: [GameCharacter] = [
|
||||
.init(key: "0x0000", name: "Mario"),
|
||||
.init(key: "0x0100", name: "Zelda")
|
||||
]
|
||||
/// Game series.
|
||||
static let gameSeries: [GameSeries] = [
|
||||
.init(key: "0x000", name: "Super Mario"),
|
||||
.init(key: "0x010", name: "The Legend of Zelda")
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user