From 13bf62913d3e274bbac564577aefeda03e0a895e Mon Sep 17 00:00:00 2001 From: Gustavo Meyer Date: Sun, 7 Jul 2024 12:17:09 -0700 Subject: [PATCH] DTPOMERSER-1001 Address Fix issues non_optional_string_data_conversion --- .github/workflows/ci.yml | 3 ++- Tests/AnyCodableTests.swift | 2 +- Tests/TransactionTypeTests.swift | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f73662b3..dbba7d92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,8 @@ jobs: - name: Lint validation run: - swiftlint lint --strict --reporter json + | swiftlint --version + | swiftlint lint --strict --reporter json - name: Code Coverage [Build report] run: | diff --git a/Tests/AnyCodableTests.swift b/Tests/AnyCodableTests.swift index 2eca3515..40cbce11 100644 --- a/Tests/AnyCodableTests.swift +++ b/Tests/AnyCodableTests.swift @@ -20,7 +20,7 @@ class AnyCodableTests: XCTestCase { // Then XCTAssertNotNil(jsonBody) - let jsonBodyString = String(data: jsonBody, as: UTF8.self) + let jsonBodyString = String(decoding: jsonBody, as: UTF8.self) XCTAssertTrue(((jsonBodyString.contains("USD")))) } diff --git a/Tests/TransactionTypeTests.swift b/Tests/TransactionTypeTests.swift index 956920cc..80cd4579 100644 --- a/Tests/TransactionTypeTests.swift +++ b/Tests/TransactionTypeTests.swift @@ -116,9 +116,9 @@ class TransactionTypeTests: XCTestCase { if httpMethod == .get { XCTAssertNil(urlRequest.httpBody, "The HTTP body should be nil") } else { - let httpBody = String(data: urlRequest.httpBody!, as: UTF8.self) + let httpBody = String(decoding: urlRequest.httpBody!, as: UTF8.self) let payloadData = try JSONEncoder().encode(payload) - let payloadString = String(data: payloadData, as: UTF8.self) + let payloadString = String(decoding: payloadData, as: UTF8.self) XCTAssertEqual(httpBody, payloadString, "The HTTP body should be equals to payload") } @@ -165,7 +165,7 @@ class TransactionTypeTests: XCTestCase { if httpMethod == .get { XCTAssertNil(urlRequest.httpBody, "The HTTP body should be nil") } else { - let query = String(data: urlRequest.httpBody!, as: UTF8.self) + let query = String(decoding: urlRequest.httpBody!, as: UTF8.self) let payloadString = payload.toGraphQl(userToken: configuration.userToken) XCTAssertEqual(query, payloadString, "The HTTP body should be equals to payload") }