Skip to content

Commit

Permalink
fix unit testing for multi-platform module
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnEstropia committed Sep 12, 2022
1 parent a5936c1 commit c923dfc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 26 deletions.
14 changes: 12 additions & 2 deletions CoreStore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ Pod::Spec.new do |s|

s.ios.deployment_target = "13.0"
s.osx.deployment_target = "10.15"
s.watchos.deployment_target = "6.0"
s.tvos.deployment_target = "13.0"
s.watchos.deployment_target = "6.0"

s.source_files = "Sources", "Sources/**/*.{swift,h,m}"
s.source_files = "Sources", "Sources/**/*.swift"
s.public_header_files = "Sources/**/*.h"
s.frameworks = "Foundation", "CoreData"
s.requires_arc = true
s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS[config=Debug]' => '-D DEBUG', 'OTHER_LDFLAGS' => '-weak_framework Combine -weak_framework SwiftUI' }

s.test_spec "CoreStoreTests" do |ts|
ts.source_files = "CoreStoreTests", "CoreStoreTests/**/*.swift", "CoreStoreTests/**/*.xcdatamodeld", "CoreStoreTests/**/*.xcdatamodel"
ts.public_header_files = "CoreStoreTests/**/*.h"
ts.resources = [ "CoreStoreTests/**/*.xcdatamodeld", "CoreStoreTests/**/*.xcdatamodel" ]
ts.preserve_paths = "CoreStoreTests/**/*.xcdatamodeld"
ts.frameworks = "Foundation", "CoreData"
ts.requires_arc = true
ts.platforms = { :ios => nil, :osx => nil, :tvos => nil, :watchos => nil }
end
end
14 changes: 7 additions & 7 deletions CoreStore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,12 @@
remoteGlobalIDString = 82BA18881C4BBCBA00A0916E;
remoteInfo = "CoreStore tvOS";
};
B5114DA528CEEE5400EEAE78 /* PBXContainerItemProxy */ = {
B5114DCB28CF0C2B00EEAE78 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2F03A52719C5C6DA005002A5 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 82BA18881C4BBCBA00A0916E;
remoteInfo = "CoreStore tvOS";
remoteGlobalIDString = B563216E1BD65082006C9394;
remoteInfo = "CoreStore watchOS";
};
B52DD17F1BE1F8CD00949AFE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
Expand Down Expand Up @@ -1878,7 +1878,7 @@
buildRules = (
);
dependencies = (
B5114DA428CEEE5400EEAE78 /* PBXTargetDependency */,
B5114DCC28CF0C2B00EEAE78 /* PBXTargetDependency */,
);
name = "CoreStoreTests watchOS";
productName = "CoreStore tvOSTests";
Expand Down Expand Up @@ -2935,10 +2935,10 @@
target = 82BA18881C4BBCBA00A0916E /* CoreStore tvOS */;
targetProxy = 82BA18941C4BBCBA00A0916E /* PBXContainerItemProxy */;
};
B5114DA428CEEE5400EEAE78 /* PBXTargetDependency */ = {
B5114DCC28CF0C2B00EEAE78 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 82BA18881C4BBCBA00A0916E /* CoreStore tvOS */;
targetProxy = B5114DA528CEEE5400EEAE78 /* PBXContainerItemProxy */;
target = B563216E1BD65082006C9394 /* CoreStore watchOS */;
targetProxy = B5114DCB28CF0C2B00EEAE78 /* PBXContainerItemProxy */;
};
B52DD1801BE1F8CD00949AFE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5114DA328CEEE5400EEAE78"
BuildableName = "CoreStoreTests watchOS.xctest"
BuildableName = "CoreStoreTests.xctest"
BlueprintName = "CoreStoreTests watchOS"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
Expand All @@ -47,7 +47,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5114DA328CEEE5400EEAE78"
BuildableName = "CoreStoreTests watchOS.xctest"
BuildableName = "CoreStoreTests.xctest"
BlueprintName = "CoreStoreTests watchOS"
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
Expand Down
2 changes: 1 addition & 1 deletion CoreStoreTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>6.2.1</string>
<string>9.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
12 changes: 6 additions & 6 deletions CoreStoreTests/ListObserverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ListObserverTests: BaseTestDataTestCase {

let indexPath = userInfo?["indexPath"] as? IndexPath
XCTAssertEqual(indexPath?.section, 0)
XCTAssertEqual(indexPath?.row, 0)
XCTAssertEqual(indexPath?.item, 0)

let object = userInfo?["object"] as? TestEntity1
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
Expand Down Expand Up @@ -220,7 +220,7 @@ class ListObserverTests: BaseTestDataTestCase {

case NSNumber(value: 101)?:
XCTAssertEqual(indexPath?.section, 1)
XCTAssertEqual(indexPath?.row, 0)
XCTAssertEqual(indexPath?.item, 0)

XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
XCTAssertEqual(object?.testNumber, NSNumber(value: 11))
Expand All @@ -231,7 +231,7 @@ class ListObserverTests: BaseTestDataTestCase {

case NSNumber(value: 102)?:
XCTAssertEqual(indexPath?.section, 0)
XCTAssertEqual(indexPath?.row, 0)
XCTAssertEqual(indexPath?.item, 0)

XCTAssertEqual(object?.testBoolean, NSNumber(value: false))
XCTAssertEqual(object?.testNumber, NSNumber(value: 22))
Expand Down Expand Up @@ -359,11 +359,11 @@ class ListObserverTests: BaseTestDataTestCase {

let fromIndexPath = userInfo?["fromIndexPath"] as? IndexPath
XCTAssertEqual(fromIndexPath?.section, 0)
XCTAssertEqual(fromIndexPath?.row, 0)
XCTAssertEqual(fromIndexPath?.item, 0)

let toIndexPath = userInfo?["toIndexPath"] as? IndexPath
XCTAssertEqual(toIndexPath?.section, 1)
XCTAssertEqual(toIndexPath?.row, 1)
XCTAssertEqual(toIndexPath?.item, 1)

let object = userInfo?["object"] as? TestEntity1
XCTAssertEqual(object?.testEntityID, NSNumber(value: 102))
Expand Down Expand Up @@ -468,7 +468,7 @@ class ListObserverTests: BaseTestDataTestCase {
let indexPath = userInfo?["indexPath"] as? IndexPath

XCTAssertEqual(indexPath?.section, 0)
XCTAssert(indexPath?.row == 0 || indexPath?.row == 1)
XCTAssert(indexPath?.item == 0 || indexPath?.item == 1)

let object = userInfo?["object"] as? TestEntity1
XCTAssertEqual(object?.isDeleted, true)
Expand Down
10 changes: 3 additions & 7 deletions CoreStoreTests/Model.xcdatamodeld/Model.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14460.32" systemVersion="17G2307" minimumToolsVersion="Xcode 4.3" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="TestEntity1AAA" representedClassName="CoreStoreTests.TestEntity1" syncable="YES">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="21G83" minimumToolsVersion="Xcode 4.3" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="TestEntity1AAA" representedClassName=".TestEntity1" syncable="YES">
<attribute name="testBoolean" optional="YES" attributeType="Boolean" usesScalarValueType="NO" syncable="YES"/>
<attribute name="testData" optional="YES" attributeType="Binary" syncable="YES"/>
<attribute name="testDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
Expand All @@ -12,7 +12,7 @@
<relationship name="testToManyUnordered" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="TestEntity1AAA" inverseName="testToOne" inverseEntity="TestEntity1AAA" syncable="YES"/>
<relationship name="testToOne" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="TestEntity1AAA" inverseName="testToManyUnordered" inverseEntity="TestEntity1AAA" syncable="YES"/>
</entity>
<entity name="TestEntity2" representedClassName="CoreStoreTests.TestEntity2" syncable="YES">
<entity name="TestEntity2" representedClassName=".TestEntity2" syncable="YES">
<attribute name="testBoolean" optional="YES" attributeType="Boolean" usesScalarValueType="NO" syncable="YES"/>
<attribute name="testData" optional="YES" attributeType="Binary" syncable="YES"/>
<attribute name="testDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
Expand All @@ -30,8 +30,4 @@
<configuration name="Config2">
<memberEntity name="TestEntity2"/>
</configuration>
<elements>
<element name="TestEntity1AAA" positionX="-63" positionY="-18" width="128" height="195"/>
<element name="TestEntity2" positionX="-63" positionY="9" width="128" height="195"/>
</elements>
</model>
3 changes: 2 additions & 1 deletion CoreStoreTests/TransactionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// SOFTWARE.
//

import Foundation
import XCTest

@testable
Expand Down Expand Up @@ -428,7 +429,7 @@ final class TransactionTests: BaseTestCase {

let indexPath = userInfo?["indexPath"] as? IndexPath
XCTAssertEqual(indexPath?.section, 0)
XCTAssertEqual(indexPath?.row, 0)
XCTAssertEqual(indexPath?.item, 0)

let object = userInfo?["object"] as? TestEntity1
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
Expand Down

0 comments on commit c923dfc

Please sign in to comment.