Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CI build #66

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
parameters:
swift-image:
type: string
default: &default-swift-image "swift:5.7"
default: &default-swift-image "swift:5.10"
influxdb-image:
type: string
default: &default-influxdb-image "influxdb:latest"
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
parameters:
xcode-version:
type: string
default: &default-xcode "13.4.1"
default: &default-xcode "15.3.0"
influxdb-package-version:
type: string
default: "2.0.4"
Expand Down Expand Up @@ -319,19 +319,14 @@ workflows:
- check-examples
- check-examples-macOS
- tests-linux:
name: tests-linux-5.3
swift-image: "swift:5.3"
name: tests-linux-5.8
swift-image: "swift:5.8"
- tests-linux:
name: tests-linux-5.4
swift-image: "swift:5.4"
name: tests-linux-5.9
swift-image: "swift:5.9"
- tests-linux:
name: tests-linux-5.5
swift-image: "swift:5.5"
- tests-linux:
name: tests-linux-5.6
swift-image: "swift:5.6"
- tests-linux:
name: tests-linux-5.7
name: tests-linux-5.10
swift-image: "swift:5.10"
- tests-macOS
nightly:
when:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.7.0 [unreleased]

### CI
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

## 1.6.0 [2022-12-01]

### Others
Expand Down
26 changes: 16 additions & 10 deletions Tests/InfluxDBSwiftApisTests/InfluxDB2APITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ final class InfluxDB2APITests: XCTestCase {
}
}

override func tearDownWithError() throws {
if let client = client {
client.close()
}
}

func testCreateInstance() {
let api = InfluxDB2API(client: client!)
XCTAssertNotNil(api)
Expand Down Expand Up @@ -79,13 +85,13 @@ class APIXCTestCase: XCTestCase {
XCTFail("Request is not defined!")
}

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

if let request = request {
request(nil, nil, checkResponse(check: checker, expectation: expectation))
}

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

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

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

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

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

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

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

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

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

private func checkResponse<ResponseType: Codable>(check: @escaping (ResponseType) -> Void,
Expand All @@ -153,7 +159,7 @@ class APIXCTestCase: XCTestCase {
guard Self.orgID.isEmpty else {
return
}
let expectation = self.expectation(description: "Cannot find my-org")
let expectation = XCTestExpectation(description: "Cannot find my-org")
api.organizationsAPI.getOrgs(limit: 100) { organizations, error in
if let error = error {
XCTFail("\(error)")
Expand All @@ -165,14 +171,14 @@ class APIXCTestCase: XCTestCase {
expectation.fulfill()
}
}
waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

private func findMyBucket() {
guard Self.bucketID.isEmpty else {
return
}
let expectation = self.expectation(description: "Cannot find my-bucket")
let expectation = XCTestExpectation(description: "Cannot find my-bucket")
api.bucketsAPI.getBuckets(limit: 100) { response, error in
if let error = error {
XCTFail("\(error)")
Expand All @@ -184,7 +190,7 @@ class APIXCTestCase: XCTestCase {
expectation.fulfill()
}
}
waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/InfluxDBSwiftApisTests/PingAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import XCTest

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

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

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

#if swift(>=5.5)
Expand Down
4 changes: 2 additions & 2 deletions Tests/InfluxDBSwiftApisTests/SecretsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SecretsAPITests: APIXCTestCase {
func testCreateSecret() {
let request = [generateName("secret"): generateName("secret")]

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

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

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}
}
24 changes: 12 additions & 12 deletions Tests/InfluxDBSwiftTests/DeleteAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class DeleteAPITests: XCTestCase {
}

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

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

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

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

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

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

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

MockURLProtocol.handler = { _, bodyData in
Expand Down Expand Up @@ -140,11 +140,11 @@ final class DeleteAPITests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

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

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

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

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

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

await waitForExpectations(timeout: 1, handler: nil)
await wait(for: [expectation], timeout: 1)
}
#endif
}
Expand Down
14 changes: 8 additions & 6 deletions Tests/InfluxDBSwiftTests/InfluxDBClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ final class InfluxDBClientTests: XCTestCase {
options: InfluxDBClient.InfluxDBOptions(bucket: "my-bucket", org: "my-org"),
protocolClasses: [MockURLProtocol.self])

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

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

func testDisableRedirect() {
let expectation = self.expectation(description: "Redirect response from API doesn't arrive")
let expectation = XCTestExpectation(description: "Redirect response from API doesn't arrive")
expectation.expectedFulfillmentCount = 2
expectation.assertForOverFulfill = false

class DisableRedirect: NSObject, URLSessionTaskDelegate {
let expectation: XCTestExpectation
Expand Down Expand Up @@ -174,12 +175,13 @@ final class InfluxDBClientTests: XCTestCase {
client.queryAPI.query(query: "from ...") { _, _ in
}

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 1)
}

func testHTTPLogging() {
TestLogHandler.content = ""
let expectation = self.expectation(description: "Success response from API doesn't arrive")
let expectation = XCTestExpectation(description: "Success response from API doesn't arrive")
expectation.assertForOverFulfill = false
LoggingSystem.bootstrap(TestLogHandler.init)

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

waitForExpectations(timeout: 1, handler: nil)
wait(for: [expectation], timeout: 5)

XCTAssertTrue(TestLogHandler.content.contains("Authorization: ***"), TestLogHandler.content)
}
Expand Down
24 changes: 12 additions & 12 deletions Tests/InfluxDBSwiftTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class IntegrationTests: XCTestCase {
}

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

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

Expand All @@ -52,8 +52,8 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

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

let query = """
from(bucket: "my-bucket")
Expand Down Expand Up @@ -84,11 +84,11 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}

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

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

Expand Down Expand Up @@ -117,8 +117,8 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

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

let query = """
from(bucket: "my-bucket")
Expand Down Expand Up @@ -146,9 +146,9 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)

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

let predicate = DeletePredicateRequest(
start: Date(2019, 10, 5),
Expand All @@ -162,9 +162,9 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)

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

client.queryAPI.query(query: query) { response, error in
if let error = error {
Expand All @@ -185,6 +185,6 @@ final class IntegrationTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
wait(for: [expectation], timeout: 5)
}
}
Loading