@@ -89,10 +89,8 @@ class DataUploadWorkerTests: XCTestCase {
8989 XCTAssertEqual ( try orchestrator. directory. files ( ) . count, 0 )
9090
9191 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`. " )
9393 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
94- XCTAssertNil ( metric. attributes [ " failure " ] )
95- XCTAssertNil ( metric. attributes [ " blockers " ] )
9694 }
9795
9896 func testItUploadsDataSequentiallyWithoutDelay_whenMaxBatchesPerUploadIsSet( ) throws {
@@ -141,11 +139,9 @@ class DataUploadWorkerTests: XCTestCase {
141139 worker. cancelSynchronously ( )
142140 XCTAssertEqual ( try orchestrator. directory. files ( ) . count, 1 )
143141
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`. " )
146144 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
147- XCTAssertNil ( metric. attributes [ " failure " ] )
148- XCTAssertNil ( metric. attributes [ " blockers " ] )
149145 }
150146
151147 func testGivenDataToUpload_whenUploadFinishesAndDoesNotNeedToBeRetried_thenDataIsDeleted( ) {
@@ -526,7 +522,7 @@ class DataUploadWorkerTests: XCTestCase {
526522 )
527523 }
528524
529- func testWhenUploadIsBlocked_itDoesSendUploadQualityTelemetry ( ) throws {
525+ func testWhenUploadIsBlocked_itDoesSendBatchBlockedTelemetry ( ) throws {
530526 // Given
531527 let telemetry = TelemetryMock ( )
532528
@@ -566,9 +562,9 @@ class DataUploadWorkerTests: XCTestCase {
566562
567563 // Then
568564 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`. " )
571566 XCTAssertEqual ( metric. attributes [ " blockers " ] as? [ String ] , [ " offline " , " low_battery " ] )
567+ XCTAssertNil ( metric. attributes [ " failure " ] )
572568 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
573569 }
574570
@@ -613,9 +609,12 @@ class DataUploadWorkerTests: XCTestCase {
613609 worker. cancelSynchronously ( )
614610
615611 // 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 " ] )
619618 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
620619 }
621620
@@ -660,13 +659,16 @@ class DataUploadWorkerTests: XCTestCase {
660659 worker. cancelSynchronously ( )
661660
662661 // 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`. " )
664665
665666 let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
666667 XCTAssertEqual ( error. message, " Data upload finished with status code: \( randomStatusCode. rawValue) " )
667668
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 " ] )
670672 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
671673 }
672674
@@ -705,13 +707,16 @@ class DataUploadWorkerTests: XCTestCase {
705707 worker. cancelSynchronously ( )
706708
707709 // 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`. " )
709713
710714 let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
711715 XCTAssertEqual ( error. message, #"Data upload finished with error - Error Domain=abc Code=0 "(null)""# )
712716
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 " ] )
715720 XCTAssertEqual ( metric. attributes [ " track " ] as? String , featureName)
716721 }
717722
@@ -751,8 +756,7 @@ class DataUploadWorkerTests: XCTestCase {
751756 let error = try XCTUnwrap ( telemetry. messages. firstError ( ) , " An error should be send to `telemetry`. " )
752757 XCTAssertEqual ( error. message, #"Failed to initiate 'some-feature' data upload - Failed to prepare upload"# )
753758
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`. " )
756760 XCTAssertEqual ( metric. attributes [ " track " ] as? String , " some-feature " )
757761 }
758762
0 commit comments