@@ -89,10 +89,8 @@ class DataUploadWorkerTests: XCTestCase {
89
89
XCTAssertEqual ( try orchestrator. directory. files ( ) . count, 0 )
90
90
91
91
XCTAssertEqual ( telemetry. messages. count, 3 )
92
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
92
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
93
93
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
94
- XCTAssertNil ( metric. attributes [ " failure " ] )
95
- XCTAssertNil ( metric. attributes [ " blockers " ] )
96
94
}
97
95
98
96
func testItUploadsDataSequentiallyWithoutDelay_whenMaxBatchesPerUploadIsSet( ) throws {
@@ -141,11 +139,9 @@ class DataUploadWorkerTests: XCTestCase {
141
139
worker. cancelSynchronously ( )
142
140
XCTAssertEqual ( try orchestrator. directory. files ( ) . count, 1 )
143
141
144
- XCTAssertEqual ( telemetry. messages. count, 2 )
145
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
142
+ XCTAssertEqual ( telemetry. messages. count, 1 )
143
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
146
144
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
147
- XCTAssertNil ( metric. attributes [ " failure " ] )
148
- XCTAssertNil ( metric. attributes [ " blockers " ] )
149
145
}
150
146
151
147
func testGivenDataToUpload_whenUploadFinishesAndDoesNotNeedToBeRetried_thenDataIsDeleted( ) {
@@ -526,7 +522,7 @@ class DataUploadWorkerTests: XCTestCase {
526
522
)
527
523
}
528
524
529
- func testWhenUploadIsBlocked_itDoesSendUploadQualityTelemetry ( ) throws {
525
+ func testWhenUploadIsBlocked_itDoesSendBatchBlockedTelemetry ( ) throws {
530
526
// Given
531
527
let telemetry = TelemetryMock ( )
532
528
@@ -566,9 +562,9 @@ class DataUploadWorkerTests: XCTestCase {
566
562
567
563
// Then
568
564
XCTAssertEqual ( telemetry. messages. count, 1 )
569
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
570
- XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " blocker " )
565
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " Batch Blocked " ) , " A Batch blocked metric should be send to `telemetry`. " )
571
566
XCTAssertEqual ( metric. attributes [ " blockers " ] as? [ String ] , [ " offline " , " low_battery " ] )
567
+ XCTAssertNil ( metric. attributes [ " failure " ] )
572
568
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
573
569
}
574
570
@@ -613,9 +609,12 @@ class DataUploadWorkerTests: XCTestCase {
613
609
worker. cancelSynchronously ( )
614
610
615
611
// Then
616
- XCTAssertEqual ( telemetry. messages. count, 1 )
617
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
618
- XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " \( randomStatusCode) " )
612
+ XCTAssertEqual ( telemetry. messages. count, 2 )
613
+ XCTAssertNotNil ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
614
+
615
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " Batch Blocked " ) , " A Batch Blocked metric should be send to `telemetry`. " )
616
+ XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " intake-code- \( randomStatusCode. rawValue) " )
617
+ XCTAssertNil ( metric. attributes [ " blockers " ] )
619
618
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
620
619
}
621
620
@@ -660,13 +659,16 @@ class DataUploadWorkerTests: XCTestCase {
660
659
worker. cancelSynchronously ( )
661
660
662
661
// Then
663
- XCTAssertEqual ( telemetry. messages. count, 2 )
662
+ XCTAssertEqual ( telemetry. messages. count, 3 )
663
+
664
+ XCTAssertNotNil ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
664
665
665
666
let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
666
667
XCTAssertEqual ( error. message, " Data upload finished with status code: \( randomStatusCode. rawValue) " )
667
668
668
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
669
- XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " \( randomStatusCode) " )
669
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " Batch Blocked " ) , " A Batch Blocked metric should be send to `telemetry`. " )
670
+ XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " intake-code- \( randomStatusCode. rawValue) " )
671
+ XCTAssertNil ( metric. attributes [ " blockers " ] )
670
672
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
671
673
}
672
674
@@ -705,13 +707,16 @@ class DataUploadWorkerTests: XCTestCase {
705
707
worker. cancelSynchronously ( )
706
708
707
709
// Then
708
- XCTAssertEqual ( telemetry. messages. count, 2 )
710
+ XCTAssertEqual ( telemetry. messages. count, 3 )
711
+
712
+ XCTAssertNotNil ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
709
713
710
714
let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
711
715
XCTAssertEqual ( error. message, #"Data upload finished with error - Error Domain=abc Code=0 "(null)""# )
712
716
713
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
714
- XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " \( nserror. code) " )
717
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " Batch Blocked " ) , " A Batch Blocked metric should be send to `telemetry`. " )
718
+ XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " network-code- \( nserror. code) " )
719
+ XCTAssertNil ( metric. attributes [ " blockers " ] )
715
720
XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
716
721
}
717
722
@@ -751,8 +756,7 @@ class DataUploadWorkerTests: XCTestCase {
751
756
let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
752
757
XCTAssertEqual ( error. message, #"Failed to initiate 'some-feature' data upload - Failed to prepare upload"# )
753
758
754
- let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_quality " ) , " An upload quality metric should be send to `telemetry`. " )
755
- XCTAssertEqual ( metric. attributes [ " failure " ] as? String , " invalid " )
759
+ let metric = try XCTUnwrap ( telemetry. messages. firstMetric ( named: " upload_cycle " ) , " An upload cycle metric should be send to `telemetry`. " )
756
760
XCTAssertEqual ( metric. attributes [ " track " ] as? String , " some-feature " )
757
761
}
758
762
0 commit comments