File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
FirebaseCore/Internal/Tests/Unit Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,20 @@ class HeartbeatTests: XCTestCase {
3636 var heartbeat : Heartbeat !
3737 var heartbeatData : Data !
3838
39+ var deterministicEncoder : JSONEncoder = {
40+ let encoder = JSONEncoder ( )
41+ encoder. outputFormatting = . sortedKeys
42+ return encoder
43+ } ( )
44+
3945 override func setUpWithError( ) throws {
4046 heartbeat = Heartbeat (
4147 agent: " dummy_agent " ,
4248 date: Date ( timeIntervalSince1970: 1_635_739_200 ) , // 2021-11-01
4349 timePeriods: [ . daily] ,
4450 version: 100
4551 )
46- heartbeatData = try JSONEncoder ( ) . encode ( heartbeat)
52+ heartbeatData = try deterministicEncoder . encode ( heartbeat)
4753 }
4854
4955 func testHeartbeatCurrentVersion( ) throws {
@@ -67,7 +73,7 @@ class HeartbeatTests: XCTestCase {
6773 let decodedHeartbeat = try JSONDecoder ( )
6874 . decode ( Heartbeat . self, from: data)
6975
70- let encodedHeartbeat = try JSONEncoder ( )
76+ let encodedHeartbeat = try deterministicEncoder
7177 . encode ( decodedHeartbeat)
7278
7379 // Then
You can’t perform that action at this time.
0 commit comments