Skip to content

Commit 2f00fcd

Browse files
authored
fix: CI build (#66)
* feat: add swift 5.10 * feat: test only on last 3 version of the swift * chore: upgrade Xcode * chore: refactor test to new API * docs: update CHANGELOG.md
1 parent 4b7e4b9 commit 2f00fcd

10 files changed

+99
-93
lines changed

.circleci/config.yml

+8-13
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
parameters:
6868
swift-image:
6969
type: string
70-
default: &default-swift-image "swift:5.7"
70+
default: &default-swift-image "swift:5.10"
7171
influxdb-image:
7272
type: string
7373
default: &default-influxdb-image "influxdb:latest"
@@ -126,7 +126,7 @@ jobs:
126126
parameters:
127127
xcode-version:
128128
type: string
129-
default: &default-xcode "13.4.1"
129+
default: &default-xcode "15.3.0"
130130
influxdb-package-version:
131131
type: string
132132
default: "2.0.4"
@@ -319,19 +319,14 @@ workflows:
319319
- check-examples
320320
- check-examples-macOS
321321
- tests-linux:
322-
name: tests-linux-5.3
323-
swift-image: "swift:5.3"
322+
name: tests-linux-5.8
323+
swift-image: "swift:5.8"
324324
- tests-linux:
325-
name: tests-linux-5.4
326-
swift-image: "swift:5.4"
325+
name: tests-linux-5.9
326+
swift-image: "swift:5.9"
327327
- tests-linux:
328-
name: tests-linux-5.5
329-
swift-image: "swift:5.5"
330-
- tests-linux:
331-
name: tests-linux-5.6
332-
swift-image: "swift:5.6"
333-
- tests-linux:
334-
name: tests-linux-5.7
328+
name: tests-linux-5.10
329+
swift-image: "swift:5.10"
335330
- tests-macOS
336331
nightly:
337332
when:

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 1.7.0 [unreleased]
22

3+
### CI
4+
1. [#55](https://github.com/influxdata/influxdb-client-swift/pull/55): Use Swift 5.8, 5.9 and 5.10 in CI and update XCode to 15.3.0
5+
36
## 1.6.0 [2022-12-01]
47

58
### Others

Tests/InfluxDBSwiftApisTests/InfluxDB2APITests.swift

+16-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ final class InfluxDB2APITests: XCTestCase {
1919
}
2020
}
2121

22+
override func tearDownWithError() throws {
23+
if let client = client {
24+
client.close()
25+
}
26+
}
27+
2228
func testCreateInstance() {
2329
let api = InfluxDB2API(client: client!)
2430
XCTAssertNotNil(api)
@@ -79,13 +85,13 @@ class APIXCTestCase: XCTestCase {
7985
XCTFail("Request is not defined!")
8086
}
8187

82-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
88+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
8389

8490
if let request = request {
8591
request(nil, nil, checkResponse(check: checker, expectation: expectation))
8692
}
8793

88-
waitForExpectations(timeout: 5, handler: nil)
94+
wait(for: [expectation], timeout: 5)
8995
}
9096

9197
func checkPost<BodyType: Codable, ResponseType: Codable>(_ request: ((BodyType,
@@ -100,13 +106,13 @@ class APIXCTestCase: XCTestCase {
100106
return
101107
}
102108

103-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
109+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
104110

105111
if let request = request {
106112
request(body, nil, checkResponse(check: checker, expectation: expectation))
107113
}
108114

109-
waitForExpectations(timeout: 5, handler: nil)
115+
wait(for: [expectation], timeout: 5)
110116
}
111117

112118
func checkPost<BodyType: Codable, ResponseType: Codable>(_ request: ((BodyType,
@@ -122,13 +128,13 @@ class APIXCTestCase: XCTestCase {
122128
return
123129
}
124130

125-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
131+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
126132

127133
if let request = request {
128134
request(body, nil, nil, checkResponse(check: checker, expectation: expectation))
129135
}
130136

131-
waitForExpectations(timeout: 5, handler: nil)
137+
wait(for: [expectation], timeout: 5)
132138
}
133139

134140
private func checkResponse<ResponseType: Codable>(check: @escaping (ResponseType) -> Void,
@@ -153,7 +159,7 @@ class APIXCTestCase: XCTestCase {
153159
guard Self.orgID.isEmpty else {
154160
return
155161
}
156-
let expectation = self.expectation(description: "Cannot find my-org")
162+
let expectation = XCTestExpectation(description: "Cannot find my-org")
157163
api.organizationsAPI.getOrgs(limit: 100) { organizations, error in
158164
if let error = error {
159165
XCTFail("\(error)")
@@ -165,14 +171,14 @@ class APIXCTestCase: XCTestCase {
165171
expectation.fulfill()
166172
}
167173
}
168-
waitForExpectations(timeout: 5, handler: nil)
174+
wait(for: [expectation], timeout: 5)
169175
}
170176

171177
private func findMyBucket() {
172178
guard Self.bucketID.isEmpty else {
173179
return
174180
}
175-
let expectation = self.expectation(description: "Cannot find my-bucket")
181+
let expectation = XCTestExpectation(description: "Cannot find my-bucket")
176182
api.bucketsAPI.getBuckets(limit: 100) { response, error in
177183
if let error = error {
178184
XCTFail("\(error)")
@@ -184,7 +190,7 @@ class APIXCTestCase: XCTestCase {
184190
expectation.fulfill()
185191
}
186192
}
187-
waitForExpectations(timeout: 5, handler: nil)
193+
wait(for: [expectation], timeout: 5)
188194
}
189195
}
190196

Tests/InfluxDBSwiftApisTests/PingAPITests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import XCTest
88

99
final class PingAPITests: APIXCTestCase {
1010
func testPing() {
11-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
11+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
1212

1313
api.pingAPI.getPing { headers, error -> Void in
1414
if let error = error {
@@ -23,7 +23,7 @@ final class PingAPITests: APIXCTestCase {
2323
expectation.fulfill()
2424
}
2525

26-
waitForExpectations(timeout: 5, handler: nil)
26+
wait(for: [expectation], timeout: 5)
2727
}
2828

2929
#if swift(>=5.5)

Tests/InfluxDBSwiftApisTests/SecretsAPITests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SecretsAPITests: APIXCTestCase {
2525
func testCreateSecret() {
2626
let request = [generateName("secret"): generateName("secret")]
2727

28-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
28+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
2929

3030
self.api.secretsAPI.patchOrgsIDSecrets(orgID: Self.orgID, requestBody: request) { _, error in
3131
if let error = error {
@@ -35,6 +35,6 @@ class SecretsAPITests: APIXCTestCase {
3535
expectation.fulfill()
3636
}
3737

38-
waitForExpectations(timeout: 5, handler: nil)
38+
wait(for: [expectation], timeout: 5)
3939
}
4040
}

Tests/InfluxDBSwiftTests/DeleteAPITests.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class DeleteAPITests: XCTestCase {
3030
}
3131

3232
func testBucketOrgParameters() {
33-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
33+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
3434
expectation.expectedFulfillmentCount = 2
3535

3636
MockURLProtocol.handler = { request, _ in
@@ -53,11 +53,11 @@ final class DeleteAPITests: XCTestCase {
5353
expectation.fulfill()
5454
}
5555

56-
waitForExpectations(timeout: 1, handler: nil)
56+
wait(for: [expectation], timeout: 1)
5757
}
5858

5959
func testBucketIDOrgIDParameters() {
60-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
60+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
6161
expectation.expectedFulfillmentCount = 2
6262

6363
MockURLProtocol.handler = { request, _ in
@@ -80,11 +80,11 @@ final class DeleteAPITests: XCTestCase {
8080
expectation.fulfill()
8181
}
8282

83-
waitForExpectations(timeout: 1, handler: nil)
83+
wait(for: [expectation], timeout: 1)
8484
}
8585

8686
func testWithoutBucketOrgParameters() {
87-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
87+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
8888
expectation.expectedFulfillmentCount = 2
8989

9090
MockURLProtocol.handler = { request, _ in
@@ -106,11 +106,11 @@ final class DeleteAPITests: XCTestCase {
106106
expectation.fulfill()
107107
}
108108

109-
waitForExpectations(timeout: 1, handler: nil)
109+
wait(for: [expectation], timeout: 1)
110110
}
111111

112112
func testPredicateRequestSerialization() {
113-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
113+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
114114
expectation.expectedFulfillmentCount = 2
115115

116116
MockURLProtocol.handler = { _, bodyData in
@@ -140,11 +140,11 @@ final class DeleteAPITests: XCTestCase {
140140
expectation.fulfill()
141141
}
142142

143-
waitForExpectations(timeout: 1, handler: nil)
143+
wait(for: [expectation], timeout: 1)
144144
}
145145

146146
func testErrorResponse() {
147-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
147+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
148148
expectation.expectedFulfillmentCount = 2
149149

150150
MockURLProtocol.handler = { request, _ in
@@ -165,12 +165,12 @@ final class DeleteAPITests: XCTestCase {
165165
expectation.fulfill()
166166
}
167167

168-
waitForExpectations(timeout: 1, handler: nil)
168+
wait(for: [expectation], timeout: 1)
169169
}
170170

171171
#if swift(>=5.5)
172172
func testDeleteAsync() async throws {
173-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
173+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
174174
expectation.expectedFulfillmentCount = 1
175175

176176
MockURLProtocol.handler = { _, _ in
@@ -187,7 +187,7 @@ final class DeleteAPITests: XCTestCase {
187187

188188
try await client.deleteAPI.delete(predicate: predicate)
189189

190-
await waitForExpectations(timeout: 1, handler: nil)
190+
await wait(for: [expectation], timeout: 1)
191191
}
192192
#endif
193193
}

Tests/InfluxDBSwiftTests/InfluxDBClientTests.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ final class InfluxDBClientTests: XCTestCase {
100100
options: InfluxDBClient.InfluxDBOptions(bucket: "my-bucket", org: "my-org"),
101101
protocolClasses: [MockURLProtocol.self])
102102

103-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
103+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
104104
expectation.expectedFulfillmentCount = 3
105105

106106
MockURLProtocol.handler = { request, _ in
@@ -126,12 +126,13 @@ final class InfluxDBClientTests: XCTestCase {
126126
expectation.fulfill()
127127
}
128128

129-
waitForExpectations(timeout: 1, handler: nil)
129+
wait(for: [expectation], timeout: 1)
130130
}
131131

132132
func testDisableRedirect() {
133-
let expectation = self.expectation(description: "Redirect response from API doesn't arrive")
133+
let expectation = XCTestExpectation(description: "Redirect response from API doesn't arrive")
134134
expectation.expectedFulfillmentCount = 2
135+
expectation.assertForOverFulfill = false
135136

136137
class DisableRedirect: NSObject, URLSessionTaskDelegate {
137138
let expectation: XCTestExpectation
@@ -174,12 +175,13 @@ final class InfluxDBClientTests: XCTestCase {
174175
client.queryAPI.query(query: "from ...") { _, _ in
175176
}
176177

177-
waitForExpectations(timeout: 1, handler: nil)
178+
wait(for: [expectation], timeout: 1)
178179
}
179180

180181
func testHTTPLogging() {
181182
TestLogHandler.content = ""
182-
let expectation = self.expectation(description: "Success response from API doesn't arrive")
183+
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
184+
expectation.assertForOverFulfill = false
183185
LoggingSystem.bootstrap(TestLogHandler.init)
184186

185187
client = InfluxDBClient(url: Self.dbURL(), token: "my-token", debugging: true)
@@ -199,7 +201,7 @@ final class InfluxDBClientTests: XCTestCase {
199201
expectation.fulfill()
200202
}
201203

202-
waitForExpectations(timeout: 1, handler: nil)
204+
wait(for: [expectation], timeout: 5)
203205

204206
XCTAssertTrue(TestLogHandler.content.contains("Authorization: ***"), TestLogHandler.content)
205207
}

Tests/InfluxDBSwiftTests/IntegrationTests.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class IntegrationTests: XCTestCase {
3333
}
3434

3535
func testQueryWriteIntegration() {
36-
var expectation = self.expectation(description: "Success response from API doesn't arrive")
36+
var expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
3737

3838
let measurement = "h2o_\(Date().timeIntervalSince1970)"
3939

@@ -52,8 +52,8 @@ final class IntegrationTests: XCTestCase {
5252
expectation.fulfill()
5353
}
5454

55-
waitForExpectations(timeout: 5, handler: nil)
56-
expectation = self.expectation(description: "Success response from API doesn't arrive")
55+
wait(for: [expectation], timeout: 5)
56+
expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
5757

5858
let query = """
5959
from(bucket: "my-bucket")
@@ -84,11 +84,11 @@ final class IntegrationTests: XCTestCase {
8484
expectation.fulfill()
8585
}
8686

87-
waitForExpectations(timeout: 5, handler: nil)
87+
wait(for: [expectation], timeout: 5)
8888
}
8989

9090
func testDelete() {
91-
var expectation = self.expectation(description: "Success response from Write API doesn't arrive")
91+
var expectation = XCTestExpectation(description: "Success response from Write API doesn't arrive")
9292

9393
let measurement = "h2o_\(Date().timeIntervalSince1970)"
9494

@@ -117,8 +117,8 @@ final class IntegrationTests: XCTestCase {
117117
expectation.fulfill()
118118
}
119119

120-
waitForExpectations(timeout: 5, handler: nil)
121-
expectation = self.expectation(description: "Success response from Query API doesn't arrive")
120+
wait(for: [expectation], timeout: 5)
121+
expectation = XCTestExpectation(description: "Success response from Query API doesn't arrive")
122122

123123
let query = """
124124
from(bucket: "my-bucket")
@@ -146,9 +146,9 @@ final class IntegrationTests: XCTestCase {
146146
expectation.fulfill()
147147
}
148148

149-
waitForExpectations(timeout: 5, handler: nil)
149+
wait(for: [expectation], timeout: 5)
150150

151-
expectation = self.expectation(description: "Success response from Delete API doesn't arrive")
151+
expectation = XCTestExpectation(description: "Success response from Delete API doesn't arrive")
152152

153153
let predicate = DeletePredicateRequest(
154154
start: Date(2019, 10, 5),
@@ -162,9 +162,9 @@ final class IntegrationTests: XCTestCase {
162162
expectation.fulfill()
163163
}
164164

165-
waitForExpectations(timeout: 5, handler: nil)
165+
wait(for: [expectation], timeout: 5)
166166

167-
expectation = self.expectation(description: "Success response from Query API doesn't arrive")
167+
expectation = XCTestExpectation(description: "Success response from Query API doesn't arrive")
168168

169169
client.queryAPI.query(query: query) { response, error in
170170
if let error = error {
@@ -185,6 +185,6 @@ final class IntegrationTests: XCTestCase {
185185
expectation.fulfill()
186186
}
187187

188-
waitForExpectations(timeout: 5, handler: nil)
188+
wait(for: [expectation], timeout: 5)
189189
}
190190
}

0 commit comments

Comments
 (0)