Skip to content

Commit

Permalink
Update to xcode 16 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndurell authored Oct 16, 2024
1 parent 02c559d commit b2a5e7c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ concurrency:
jobs:
library:
name: Build and Run Unit Tests
runs-on: macos-13
runs-on: macos-14
strategy:
matrix:
xcode: ['14.3.1', '15.1']
xcode: ['15.2', '15.4', '16.0']
config: ['debug', 'release']
steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Run ${{ matrix.config }} tests
run: make CONFIG=${{ matrix.config }} test-library

- uses: kishikawakatsumi/xcresulttool@v1
- uses: conradev/xcresulttool@v1.8.0
with:
path: TestResults.xcresult
if: success() || failure()
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CONFIG = debug
PLATFORM_IOS = iOS Simulator,name=iPhone 14
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])


default: test-all

Expand All @@ -15,3 +16,7 @@ test-library:
-scheme klaviyo-swift-sdk-Package \
-destination platform="$$platform" || exit 1; \
done;

define udid_for
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
endef
2 changes: 1 addition & 1 deletion Sources/KlaviyoSwift/StateManagement/StateManagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ struct KlaviyoReducer: ReducerProtocol {
state.flushing = false
return .none
}
return .task { .sendRequest }
return .task { .sendRequest }.cancellable(id: RequestId.self)

case .sendRequest:
guard case .initialized = state.initalizationState else {
Expand Down
10 changes: 5 additions & 5 deletions Tests/KlaviyoCoreTests/TestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ let TEST_FAILURE_JSON_INVALID_EMAIL = """
"""

let SAMPLE_PROPERTIES = [
"blob": "blob",
"stuff": 2,
"hello": [
"sub": "dict"
"Blob": "blob",
"Stuff": 2,
"Hello": [
"Sub": "dict"
]
] as [String: Any]

Expand Down Expand Up @@ -142,7 +142,7 @@ extension NetworkSession {
}
}

class TestJSONDecoder: JSONDecoder {
class TestJSONDecoder: JSONDecoder, @unchecked Sendable {
override func decode<T>(_: T.Type, from _: Data) throws -> T where T: Decodable {
AppLifeCycleEvents.test as! T
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
"App ID" : "com.klaviyo.fooapp",
"App Name" : "FooApp",
"App Version" : "1.2.3",
"blob" : "blob",
"Blob" : "blob",
"Device ID" : "fe-fi-fo-fum",
"Device Manufacturer" : "Orange",
"Device Model" : "jPhone 1,1",
"hello" : {
"sub" : "dict"
"Hello" : {
"Sub" : "dict"
},
"OS Name" : "iOS",
"OS Version" : "1.1.1",
"Push Token" : "",
"SDK Name" : "swift",
"SDK Version" : "4.0.0",
"stuff" : 2
"Stuff" : 2
},
"time" : "2009-02-13T23:31:30Z",
"unique_id" : "00000000-0000-0000-0000-000000000001"
Expand Down
4 changes: 2 additions & 2 deletions Tests/KlaviyoSwiftTests/KlaviyoTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ extension KlaviyoEnvironment {
}
}

class TestJSONDecoder: JSONDecoder {
class TestJSONDecoder: JSONDecoder, @unchecked Sendable {
override func decode<T>(_: T.Type, from _: Data) throws -> T where T: Decodable {
KlaviyoState.test as! T
}
}

class InvalidJSONDecoder: JSONDecoder {
class InvalidJSONDecoder: JSONDecoder, @unchecked Sendable {
override func decode<T>(_: T.Type, from _: Data) throws -> T where T: Decodable {
throw KlaviyoDecodingError.invalidType
}
Expand Down
7 changes: 7 additions & 0 deletions Tests/KlaviyoSwiftTests/StateManagementEdgeCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ class StateManagementEdgeCaseTests: XCTestCase {
}
}

@MainActor
func testSetEmptyEmail() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setEmail(""))
}

@MainActor
func testSetEmailWithWhiteSpace() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())
Expand Down Expand Up @@ -199,13 +201,15 @@ class StateManagementEdgeCaseTests: XCTestCase {
}
}

@MainActor
func testSetEmptyExternalId() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setExternalId(""))
}

@MainActor
func testSetExternalIdWithWhiteSpaces() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())
Expand Down Expand Up @@ -243,13 +247,15 @@ class StateManagementEdgeCaseTests: XCTestCase {
}
}

@MainActor
func testSetEmptyPhoneNumber() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setPhoneNumber(""))
}

@MainActor
func testSetPhoneNumberWithWhiteSpaces() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())
Expand Down Expand Up @@ -414,6 +420,7 @@ class StateManagementEdgeCaseTests: XCTestCase {
await fulfillment(of: [expection])
}

@MainActor
func testSetProfileWithEmptyStringIdentifiers() async throws {
let initialState = KlaviyoState(
apiKey: TEST_API_KEY,
Expand Down

0 comments on commit b2a5e7c

Please sign in to comment.