Skip to content

Commit dfbd6d4

Browse files
committed
Add ConsistencyManagerTestHelpers to tests
* Has helper methods for repeating functionality
1 parent 64c25b6 commit dfbd6d4

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
@@ -64,6 +64,7 @@
6464
3C0C67262D4946BD00F80448 /* OneSignalCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DE7D17E627026B95002D3A5D /* OneSignalCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6565
3C0C67372D49503E00F80448 /* UIApplication+OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C0C672F2D49501D00F80448 /* UIApplication+OneSignal.m */; };
6666
3C0C67382D49505700F80448 /* UIApplication+OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C0C672E2D49501D00F80448 /* UIApplication+OneSignal.h */; };
67+
3C0C673A2D49540700F80448 /* ConsistencyManagerTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0C67392D49540700F80448 /* ConsistencyManagerTestHelpers.swift */; };
6768
3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */; };
6869
3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */ = {isa = PBXBuildFile; fileRef = 3C115164289A259500565C41 /* OneSignalOSCore.docc */; };
6970
3C115171289A259500565C41 /* OneSignalOSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C115163289A259500565C41 /* OneSignalOSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1282,6 +1283,7 @@
12821283
3C0C67222D49469200F80448 /* MockMessagingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockMessagingController.m; sourceTree = "<group>"; };
12831284
3C0C672E2D49501D00F80448 /* UIApplication+OneSignal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIApplication+OneSignal.h"; sourceTree = "<group>"; };
12841285
3C0C672F2D49501D00F80448 /* UIApplication+OneSignal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIApplication+OneSignal.m"; sourceTree = "<group>"; };
1286+
3C0C67392D49540700F80448 /* ConsistencyManagerTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsistencyManagerTestHelpers.swift; sourceTree = "<group>"; };
12851287
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSUserInternalImpl.swift; sourceTree = "<group>"; };
12861288
3C115161289A259500565C41 /* OneSignalOSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OneSignalOSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
12871289
3C115163289A259500565C41 /* OneSignalOSCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalOSCore.h; sourceTree = "<group>"; };
@@ -2203,6 +2205,7 @@
22032205
isa = PBXGroup;
22042206
children = (
22052207
3C8544B82C5AEFF700F542A9 /* OneSignalOSCoreMocks.h */,
2208+
3C0C67392D49540700F80448 /* ConsistencyManagerTestHelpers.swift */,
22062209
3C8544C22C5AF18B00F542A9 /* OSCoreMocks.swift */,
22072210
3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */,
22082211
);
@@ -4320,6 +4323,7 @@
43204323
isa = PBXSourcesBuildPhase;
43214324
buildActionMask = 2147483647;
43224325
files = (
4326+
3C0C673A2D49540700F80448 /* ConsistencyManagerTestHelpers.swift in Sources */,
43234327
3C8544C32C5AF18B00F542A9 /* OSCoreMocks.swift in Sources */,
43244328
3CF11E402C6E6DE2002856F5 /* MockNewRecordsState.swift in Sources */,
43254329
);
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)