Skip to content

Commit 1302dbd

Browse files
Merge pull request #3 from NeedleInAJayStack/fix/tests
Fixes tests & impoves platform isolation
2 parents bd945ee + 36c6fc3 commit 1302dbd

29 files changed

+146
-72
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push: { branches: [ main ] }
55

66
jobs:
7-
darwin-test:
7+
macos-test:
88
runs-on: macos-latest
99
steps:
1010
- uses: maxim-lobanov/setup-xcode@v1
@@ -13,11 +13,11 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- name: Darwin build & test
1515
run: swift test --skip IntegrationTests
16-
linux-build:
16+
linux-test:
1717
runs-on: ubuntu-latest
1818
container:
1919
image: swift:latest
2020
steps:
2121
- uses: actions/checkout@v2
22-
- name: Linux build
23-
run: swift build --target HaystackClientNIO
22+
- name: Linux build & test
23+
run: swift test --skip IntegrationTests

Package.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import PackageDescription
44

5+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
56
let package = Package(
67
name: "Haystack",
78
platforms: [
@@ -81,3 +82,60 @@ let package = Package(
8182
),
8283
]
8384
)
85+
#else
86+
let package = Package(
87+
name: "Haystack",
88+
products: [
89+
.library(
90+
name: "Haystack",
91+
targets: ["Haystack"]
92+
),
93+
.library(
94+
name: "HaystackClientNIO",
95+
targets: [
96+
"HaystackClient",
97+
"HaystackClientNIO"
98+
]
99+
),
100+
],
101+
dependencies: [
102+
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "3.0.0"),
103+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0")
104+
],
105+
targets: [
106+
.target(
107+
name: "Haystack",
108+
dependencies: []
109+
),
110+
.target(
111+
name: "HaystackClient",
112+
dependencies: [
113+
"Haystack",
114+
.product(name: "Crypto", package: "swift-crypto"),
115+
]
116+
),
117+
.target(
118+
name: "HaystackClientNIO",
119+
dependencies: [
120+
"Haystack",
121+
"HaystackClient",
122+
.product(name: "AsyncHTTPClient", package: "async-http-client"),
123+
]
124+
),
125+
126+
// Tests
127+
.testTarget(
128+
name: "HaystackTests",
129+
dependencies: ["Haystack"]
130+
),
131+
.testTarget(
132+
name: "HaystackClientTests",
133+
dependencies: ["HaystackClient"]
134+
),
135+
.testTarget(
136+
name: "HaystackClientNIOIntegrationTests",
137+
dependencies: ["HaystackClientNIO"]
138+
),
139+
]
140+
)
141+
#endif

Sources/Haystack/Coord.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension Coord: Codable {
3939
/// Read from decodable data
4040
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#coord)
4141
public init(from decoder: Decoder) throws {
42-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
42+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
4343
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
4444
throw DecodingError.typeMismatch(
4545
Self.self,
@@ -68,7 +68,7 @@ extension Coord: Codable {
6868
/// Write to encodable data
6969
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#coord)
7070
public func encode(to encoder: Encoder) throws {
71-
var container = encoder.container(keyedBy: Self.CodingKeys)
71+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
7272
try container.encode(Self.kindValue, forKey: ._kind)
7373
try container.encode(latitude, forKey: .lat)
7474
try container.encode(longitude, forKey: .lng)

Sources/Haystack/Date.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ extension Date {
7373
/// Read from decodable data
7474
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#date)
7575
public init(from decoder: Decoder) throws {
76-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
76+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
7777
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
7878
throw DecodingError.typeMismatch(
7979
Self.self,
@@ -110,7 +110,7 @@ extension Date {
110110
/// Write to encodable data
111111
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#date)
112112
public func encode(to encoder: Encoder) throws {
113-
var container = encoder.container(keyedBy: Self.CodingKeys)
113+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
114114
try container.encode(Self.kindValue, forKey: ._kind)
115115
try container.encode(isoString, forKey: .val)
116116
}

Sources/Haystack/DateTime.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ extension DateTime {
206206
/// Read from decodable data
207207
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#dateTime)
208208
public init(from decoder: Decoder) throws {
209-
guard let container = try? decoder.container(keyedBy: Self.CodingKeys) else {
209+
guard let container = try? decoder.container(keyedBy: Self.CodingKeys.self) else {
210210
throw DecodingError.typeMismatch(
211211
Self.self,
212212
.init(
@@ -248,7 +248,7 @@ extension DateTime {
248248
/// Write to encodable data
249249
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#dateTime)
250250
public func encode(to encoder: Encoder) throws {
251-
var container = encoder.container(keyedBy: Self.CodingKeys)
251+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
252252
try container.encode(Self.kindValue, forKey: ._kind)
253253
let isoString: String
254254
if hasMilliseconds {

Sources/Haystack/Grid.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ extension Grid {
7676
/// Read from decodable data
7777
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#grid)
7878
public init(from decoder: Decoder) throws {
79-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
79+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
8080
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
8181
throw DecodingError.typeMismatch(
8282
Self.self,
@@ -110,7 +110,7 @@ extension Grid {
110110
/// Write to encodable data
111111
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#grid)
112112
public func encode(to encoder: Encoder) throws {
113-
var container = encoder.container(keyedBy: Self.CodingKeys)
113+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
114114
try container.encode(Self.kindValue, forKey: ._kind)
115115
try container.encode(meta, forKey: .meta)
116116
if cols.isEmpty {

Sources/Haystack/Marker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extension Marker {
3333
/// Read from decodable data
3434
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#marker)
3535
public init(from decoder: Decoder) throws {
36-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
36+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
3737
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
3838
throw DecodingError.typeMismatch(
3939
Self.self,
@@ -58,7 +58,7 @@ extension Marker {
5858
/// Write to encodable data
5959
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#marker)
6060
public func encode(to encoder: Encoder) throws {
61-
var container = encoder.container(keyedBy: Self.CodingKeys)
61+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
6262
try container.encode(Self.kindValue, forKey: ._kind)
6363
}
6464
}

Sources/Haystack/NA.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extension NA {
3333
/// Read from decodable data
3434
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#na)
3535
public init(from decoder: Decoder) throws {
36-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
36+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
3737
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
3838
throw DecodingError.typeMismatch(
3939
Self.self,
@@ -58,7 +58,7 @@ extension NA {
5858
/// Write to encodable data
5959
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#na)
6060
public func encode(to encoder: Encoder) throws {
61-
var container = encoder.container(keyedBy: Self.CodingKeys)
61+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
6262
try container.encode(Self.kindValue, forKey: ._kind)
6363
}
6464
}

Sources/Haystack/Number.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension Number {
7070
/// Read from decodable data
7171
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#number)
7272
public init(from decoder: Decoder) throws {
73-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
73+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
7474
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
7575
throw DecodingError.typeMismatch(
7676
Self.self,
@@ -129,7 +129,7 @@ extension Number {
129129
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#number)
130130
public func encode(to encoder: Encoder) throws {
131131
if unit != nil || val.isNaN || val.isInfinite {
132-
var container = encoder.container(keyedBy: Self.CodingKeys)
132+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
133133
try container.encode(Self.kindValue, forKey: ._kind)
134134

135135
if val.isNaN {

Sources/Haystack/Ref.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension Ref {
4545
/// Read from decodable data
4646
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#ref)
4747
public init(from decoder: Decoder) throws {
48-
if let container = try? decoder.container(keyedBy: Self.CodingKeys) {
48+
if let container = try? decoder.container(keyedBy: Self.CodingKeys.self) {
4949
guard try container.decode(String.self, forKey: ._kind) == Self.kindValue else {
5050
throw DecodingError.typeMismatch(
5151
Self.self,
@@ -74,7 +74,7 @@ extension Ref {
7474
/// Write to encodable data
7575
/// See [JSON format](https://project-haystack.org/doc/docHaystack/Json#ref)
7676
public func encode(to encoder: Encoder) throws {
77-
var container = encoder.container(keyedBy: Self.CodingKeys)
77+
var container = encoder.container(keyedBy: Self.CodingKeys.self)
7878
try container.encode(Self.kindValue, forKey: ._kind)
7979
try container.encode(val, forKey: .val)
8080
try container.encode(dis, forKey: .dis)

0 commit comments

Comments
 (0)