Skip to content

Commit bc8119e

Browse files
committed
chore(tests): Add ConsistencyManagerTestHelpers to tests
* Has helper methods for repeating functionality
1 parent 801d3a1 commit bc8119e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
3C70222D2ECF12A5001768C6 /* IAMTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C70222C2ECF12A5001768C6 /* IAMTestHelpers.swift */; };
106106
3C7022302ECF1620001768C6 /* MockMessagingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C70222F2ECF1620001768C6 /* MockMessagingController.m */; };
107107
3C7022312ECF1620001768C6 /* MockMessagingController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C70222E2ECF1620001768C6 /* MockMessagingController.h */; settings = {ATTRIBUTES = (Public, ); }; };
108+
3C7022332ECF2305001768C6 /* ConsistencyManagerTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C7022322ECF2305001768C6 /* ConsistencyManagerTestHelpers.swift */; };
108109
3C70FA672D0B68A100031066 /* OneSignalClientError.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C70FA652D0B68A100031066 /* OneSignalClientError.h */; settings = {ATTRIBUTES = (Public, ); }; };
109110
3C70FA682D0B68A100031066 /* OneSignalClientError.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C70FA662D0B68A100031066 /* OneSignalClientError.m */; };
110111
3C789DBD293C2206004CF83D /* OSFocusInfluenceParam.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A600B432453790700514A53 /* OSFocusInfluenceParam.m */; };
@@ -1308,6 +1309,7 @@
13081309
3C70222C2ECF12A5001768C6 /* IAMTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IAMTestHelpers.swift; sourceTree = "<group>"; };
13091310
3C70222E2ECF1620001768C6 /* MockMessagingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockMessagingController.h; sourceTree = "<group>"; };
13101311
3C70222F2ECF1620001768C6 /* MockMessagingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockMessagingController.m; sourceTree = "<group>"; };
1312+
3C7022322ECF2305001768C6 /* ConsistencyManagerTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsistencyManagerTestHelpers.swift; sourceTree = "<group>"; };
13111313
3C70FA652D0B68A100031066 /* OneSignalClientError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalClientError.h; sourceTree = "<group>"; };
13121314
3C70FA662D0B68A100031066 /* OneSignalClientError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalClientError.m; sourceTree = "<group>"; };
13131315
3C7A39D42B7C18EE0082665E /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
@@ -2189,6 +2191,7 @@
21892191
isa = PBXGroup;
21902192
children = (
21912193
3C8544B82C5AEFF700F542A9 /* OneSignalOSCoreMocks.h */,
2194+
3C7022322ECF2305001768C6 /* ConsistencyManagerTestHelpers.swift */,
21922195
3C8544C22C5AF18B00F542A9 /* OSCoreMocks.swift */,
21932196
3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */,
21942197
);
@@ -4322,6 +4325,7 @@
43224325
isa = PBXSourcesBuildPhase;
43234326
buildActionMask = 2147483647;
43244327
files = (
4328+
3C7022332ECF2305001768C6 /* ConsistencyManagerTestHelpers.swift in Sources */,
43254329
3C8544C32C5AF18B00F542A9 /* OSCoreMocks.swift in Sources */,
43264330
3CF11E402C6E6DE2002856F5 /* MockNewRecordsState.swift in Sources */,
43274331
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Modified MIT License
3+
4+
Copyright 2025 OneSignal
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
1. The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
2. All copies of substantial portions of the Software may only be used in connection
17+
with services provided by OneSignal.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
*/
27+
28+
import OneSignalOSCore
29+
30+
public class ConsistencyManagerTestHelpers {
31+
/// Unblocks the Consistency Manager, which allows fetching of IAMs for example.
32+
public static func setDefaultRywToken(id: String) {
33+
let key = OSIamFetchOffsetKey.userUpdate
34+
let rywToken = "123"
35+
let rywDelay: NSNumber = 0
36+
let rywData = OSReadYourWriteData(rywToken: rywToken, rywDelay: rywDelay)
37+
OSConsistencyManager.shared.setRywTokenAndDelay(id: id, key: key, value: rywData)
38+
}
39+
}

0 commit comments

Comments
 (0)