File tree 1 file changed +8
-2
lines changed
FirebaseCore/Internal/Tests/Unit
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,20 @@ class HeartbeatTests: XCTestCase {
36
36
var heartbeat : Heartbeat !
37
37
var heartbeatData : Data !
38
38
39
+ var deterministicEncoder : JSONEncoder = {
40
+ let encoder = JSONEncoder ( )
41
+ encoder. outputFormatting = . sortedKeys
42
+ return encoder
43
+ } ( )
44
+
39
45
override func setUpWithError( ) throws {
40
46
heartbeat = Heartbeat (
41
47
agent: " dummy_agent " ,
42
48
date: Date ( timeIntervalSince1970: 1_635_739_200 ) , // 2021-11-01
43
49
timePeriods: [ . daily] ,
44
50
version: 100
45
51
)
46
- heartbeatData = try JSONEncoder ( ) . encode ( heartbeat)
52
+ heartbeatData = try deterministicEncoder . encode ( heartbeat)
47
53
}
48
54
49
55
func testHeartbeatCurrentVersion( ) throws {
@@ -67,7 +73,7 @@ class HeartbeatTests: XCTestCase {
67
73
let decodedHeartbeat = try JSONDecoder ( )
68
74
. decode ( Heartbeat . self, from: data)
69
75
70
- let encodedHeartbeat = try JSONEncoder ( )
76
+ let encodedHeartbeat = try deterministicEncoder
71
77
. encode ( decodedHeartbeat)
72
78
73
79
// Then
You can’t perform that action at this time.
0 commit comments