Skip to content

Commit

Permalink
Refactor the test target for supported platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed Dec 29, 2023
1 parent 5242ebf commit 7bb4a64
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
name: "tvOS"
scheme: "Flare"
sdk: appletvsimulator
- destination: "OS=9.1,name=Apple Watch Series 8 (45mm)"
name: "watchOS"
scheme: "Flare"
sdk: watchsimulator
# - destination: "OS=9.1,name=Apple Watch Series 8 (45mm)"
# name: "watchOS"
# scheme: "Flare"
# sdk: watchsimulator
- destination: "platform=macOS"
name: "macOS"
scheme: "Flare"
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ lint:
fmt:
mint run swiftformat Sources Tests

.PHONY: all bootstrap hook mint lint fmt
generate:
xcodegen generate

.PHONY: all bootstrap hook mint lint fmt generate
3 changes: 1 addition & 2 deletions Tests/FlareTests/UnitTestHostApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import SwiftUI

#if os(watchOS) || os(tvOS)
#if os(watchOS) || os(tvOS) || os(macOS)

@main
struct TestApp: App {
Expand All @@ -17,7 +17,6 @@ import SwiftUI
}

#else

// Scene isn't available until iOS 14.0, so this is for backwards compatibility.

@main
Expand Down
2 changes: 1 addition & 1 deletion Tests/FlareTests/UnitTestHostApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>4.32.0</string>
<string>1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
6 changes: 6 additions & 0 deletions Tests/FlareTests/UnitTests/FlareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class FlareTests: StoreSessionTestCase {
}
#endif

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatFlarePurchasesAProductWithOptions_whenPurchaseCompleted() async throws {
let transaction = StoreTransactionStub()
try await test_purchaseWithOptionsAndCompletion(
Expand All @@ -251,13 +252,15 @@ class FlareTests: StoreSessionTestCase {
)
}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatFlarePurchaseThrowsAnError_whenPaymentNotAllowed() async throws {
try await test_purchaseWithOptionsAndCompletion(
canMakePayments: false,
expectedResult: .failure(IAPError.paymentNotAllowed)
)
}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatFlarePurchasesAsyncAProductWithOptionsAndCompletionHandler_whenPurchaseCompleted() async throws {
let transaction = StoreTransactionStub()
try await test_purchaseWithOptions(
Expand All @@ -266,6 +269,7 @@ class FlareTests: StoreSessionTestCase {
)
}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatFlarePurchaseAsyncThrowsAnError_whenPaymentNotAllowed() async throws {
try await test_purchaseWithOptions(
canMakePayments: false,
Expand All @@ -275,6 +279,7 @@ class FlareTests: StoreSessionTestCase {

// MARK: Private

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
private func test_purchaseWithOptionsAndCompletion(
transaction: StoreTransactionStub? = nil,
canMakePayments: Bool,
Expand Down Expand Up @@ -302,6 +307,7 @@ class FlareTests: StoreSessionTestCase {
XCTAssertEqual(result, expectedResult)
}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
private func test_purchaseWithOptions(
transaction: StoreTransactionStub? = nil,
canMakePayments: Bool,
Expand Down
2 changes: 2 additions & 0 deletions Tests/FlareTests/UnitTests/Providers/IAPProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class IAPProviderTests: XCTestCase {
}
#endif

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatIAPProviderPurchasesAProduct() async throws {
// given
let transactionMock = StoreTransactionMock()
Expand All @@ -309,6 +310,7 @@ class IAPProviderTests: XCTestCase {
XCTAssertEqual(transaction.transactionIdentifier, .transactionID)
}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
func test_thatIAPProviderPurchasesAProductWithOptions() async throws {
// given
let transactionMock = StoreTransactionMock()
Expand Down
16 changes: 8 additions & 8 deletions project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: Flare
options:
deploymentTarget:
iOS: 13.0
macOS: 10.15
tvOS: 13.0
watchOS: 7.0
packages:
# External

Expand All @@ -8,23 +14,18 @@ packages:
ObjectsFactory:
url: https://github.com/space-code/objects-factory.git
from: 1.0.0

# Flare:
# path: .

targets:
UnitTestHostApp:
type: application
supportedDestinations: [iOS, tvOS, macOS, watchOS]
supportedDestinations: [iOS, tvOS, macOS]
sources: Tests/FlareTests/UnitTestHostApp
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: com.spacecode.flare
DEVELOPMENT_TEAM: A8WE5LL2GU
scheme:
testTargets:
- FlareTests
# dependencies:
# - package: Flare
Flare:
type: framework
supportedDestinations: [iOS, tvOS, macOS, watchOS]
Expand All @@ -44,7 +45,6 @@ targets:
FlareTests:
type: bundle.unit-test
supportedDestinations: [iOS, tvOS, macOS, watchOS]
# targets: ["1"]
dependencies:
- package: Concurrency
product: TestConcurrency
Expand Down

0 comments on commit 7bb4a64

Please sign in to comment.