From 954b706f6f1184e762424214a2203da0b866d9b9 Mon Sep 17 00:00:00 2001 From: Francesco Paolo Severino Date: Sun, 10 Nov 2024 17:39:06 +0100 Subject: [PATCH] Update to Swift 6 --- Package.swift | 11 ++++----- Tests/ImperialTests/ImperialTests.swift | 7 +++--- Tests/ImperialTests/ShopifyTests.swift | 32 ++++++++++++------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Package.swift b/Package.swift index 65bb98ff..7076f102 100755 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 import PackageDescription let package = Package( @@ -56,16 +56,13 @@ let package = Package( .target(name: "ImperialMicrosoft", dependencies: ["ImperialCore"], swiftSettings: swiftSettings), .target(name: "ImperialShopify", dependencies: ["ImperialCore"], swiftSettings: swiftSettings), .testTarget(name: "ImperialTests", dependencies: ["ImperialCore", "ImperialShopify"], swiftSettings: swiftSettings), - ] + ], + swiftLanguageModes: [.v5] ) var swiftSettings: [SwiftSetting] { [ .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("ConciseMagicFile"), - .enableUpcomingFeature("ForwardTrailingClosures"), - .enableUpcomingFeature("DisableOutwardActorInference"), - .enableUpcomingFeature("StrictConcurrency"), - .enableExperimentalFeature("StrictConcurrency=complete"), + .enableUpcomingFeature("FullTypedThrows"), ] } \ No newline at end of file diff --git a/Tests/ImperialTests/ImperialTests.swift b/Tests/ImperialTests/ImperialTests.swift index 6f3d3194..8ccde3d2 100644 --- a/Tests/ImperialTests/ImperialTests.swift +++ b/Tests/ImperialTests/ImperialTests.swift @@ -1,6 +1,7 @@ -import XCTest +import Testing + @testable import ImperialCore -class ImperialTests: XCTestCase { - func testExists() {} +struct ImperialTests { + @Test func empty() {} } diff --git a/Tests/ImperialTests/ShopifyTests.swift b/Tests/ImperialTests/ShopifyTests.swift index 28ffd31c..dbde17b5 100644 --- a/Tests/ImperialTests/ShopifyTests.swift +++ b/Tests/ImperialTests/ShopifyTests.swift @@ -1,40 +1,40 @@ +import Foundation +import Testing + @testable import ImperialShopify -import XCTest -final class ShopifyTests: XCTestCase { - - func testDomainCheck() throws { - +@Suite("Shopify Tests") +struct ShopifyTests { + @Test("Valid Shopify Domain") func domainCheck() throws { let domain = "davidmuzi.myshopify.com" - XCTAssertTrue(URL(string: domain)!.isValidShopifyDomain()) + #expect(URL(string: domain)!.isValidShopifyDomain()) let domain2 = "d4m3.myshopify.com" - XCTAssertTrue(URL(string: domain2)!.isValidShopifyDomain()) + #expect(URL(string: domain2)!.isValidShopifyDomain()) let domain3 = "david-muzi.myshopify.com" - XCTAssertTrue(URL(string: domain3)!.isValidShopifyDomain()) + #expect(URL(string: domain3)!.isValidShopifyDomain()) let domain4 = "david.muzi.myshopify.com" - XCTAssertTrue(URL(string: domain4)!.isValidShopifyDomain()) + #expect(URL(string: domain4)!.isValidShopifyDomain()) let domain5 = "david#muzi.myshopify.com" - XCTAssertFalse(URL(string: domain5)!.isValidShopifyDomain()) + #expect(!URL(string: domain5)!.isValidShopifyDomain()) let domain6 = "davidmuzi.myshopify.com.ca" - XCTAssertFalse(URL(string: domain6)!.isValidShopifyDomain()) + #expect(!URL(string: domain6)!.isValidShopifyDomain()) let domain7 = "davidmuzi.square.com" - XCTAssertFalse(URL(string: domain7)!.isValidShopifyDomain()) + #expect(!URL(string: domain7)!.isValidShopifyDomain()) let domain8 = "david*muzi.shopify.ca" - XCTAssertFalse(URL(string: domain8)!.isValidShopifyDomain()) + #expect(!URL(string: domain8)!.isValidShopifyDomain()) } - func testHMACValidation() throws { - + @Test("HMAC Validation") func hmacValidation() throws { let url = URL(string: "https://domain.com/?code=0907a61c0c8d55e99db179b68161bc00&hmac=700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf&shop=some-shop.myshopify.com&state=0.6784241404160823×tamp=1337178173")! let hmac = url.generateHMAC(key: "hush") - XCTAssertEqual(hmac, "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf") + #expect(hmac == "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf") } }