@@ -803,52 +803,66 @@ void main() {
803
803
check (store).isLoading.isTrue ();
804
804
}
805
805
806
- test ('report non-transient errors' , () => awaitFakeAsync ((async ) async {
807
- await prepare ();
806
+ Subject <String > checkReported (void Function () prepareError) {
807
+ return awaitFakeAsync ((async ) async {
808
+ await prepare ();
809
+ prepareError ();
810
+ pollAndFail (async );
811
+ return check (takeLastReportedError ()).isNotNull ();
812
+ });
813
+ }
808
814
809
- prepareZulipApiExceptionBadRequest ();
810
- pollAndFail (async );
811
- check (takeLastReportedError ()).isNotNull ().startsWith (
812
- "Error connecting to Zulip. Retrying…\n "
813
- "Error connecting to Zulip at" );
814
- }));
815
+ Subject <String > checkLateReported (void Function () prepareError) {
816
+ return awaitFakeAsync ((async ) async {
817
+ await prepare ();
818
+
819
+ for (int i = 0 ; i < UpdateMachine .transientFailureCountNotifyThreshold; i++ ) {
820
+ prepareError ();
821
+ pollAndFail (async );
822
+ check (takeLastReportedError ()).isNull ();
823
+ async .flushTimers ();
824
+ }
825
+
826
+ prepareError ();
827
+ pollAndFail (async );
828
+ return check (takeLastReportedError ()).isNotNull ();
829
+ });
830
+ }
815
831
816
- test ('report transient errors' , () => awaitFakeAsync ((async ) async {
817
- await prepare ();
832
+ void checkNotReported (void Function () prepareError) {
833
+ return awaitFakeAsync ((async ) async {
834
+ await prepare ();
818
835
819
- // There should be no user visible error messages during these retries.
820
- for (int i = 0 ; i < UpdateMachine .transientFailureCountNotifyThreshold; i++ ) {
821
- prepareServer5xxException ();
836
+ for (int i = 0 ; i < UpdateMachine .transientFailureCountNotifyThreshold; i++ ) {
837
+ prepareError ();
838
+ pollAndFail (async );
839
+ check (takeLastReportedError ()).isNull ();
840
+ async .flushTimers ();
841
+ }
842
+
843
+ prepareError ();
822
844
pollAndFail (async );
845
+ // Still no error reported, even after the same number of iterations
846
+ // where other errors get reported (as [checkLateReported] checks).
823
847
check (takeLastReportedError ()).isNull ();
824
- // This skips the pending polling backoff.
825
- async .flushTimers ();
826
- }
848
+ });
849
+ }
827
850
828
- prepareServer5xxException ();
829
- pollAndFail (async );
830
- check (takeLastReportedError ()).isNotNull ().startsWith (
851
+ test ('report generic ZulipApiException' , () {
852
+ checkReported (prepareZulipApiExceptionBadRequest).startsWith (
831
853
"Error connecting to Zulip. Retrying…\n "
832
854
"Error connecting to Zulip at" );
833
- })) ;
855
+ });
834
856
835
- test ('ignore boring errors' , () => awaitFakeAsync ((async ) async {
836
- await prepare ();
857
+ test ('eventually report Server5xxException' , () {
858
+ checkLateReported (prepareServer5xxException).startsWith (
859
+ "Error connecting to Zulip. Retrying…\n "
860
+ "Error connecting to Zulip at" );
861
+ });
837
862
838
- for (int i = 0 ; i < UpdateMachine .transientFailureCountNotifyThreshold; i++ ) {
839
- prepareNetworkExceptionSocketException ();
840
- pollAndFail (async );
841
- check (takeLastReportedError ()).isNull ();
842
- // This skips the pending polling backoff.
843
- async .flushTimers ();
844
- }
845
-
846
- prepareNetworkExceptionSocketException ();
847
- pollAndFail (async );
848
- // Normally we start showing user visible error messages for transient
849
- // errors after enough number of retries.
850
- check (takeLastReportedError ()).isNull ();
851
- }));
863
+ test ('ignore NetworkException from SocketException' , () {
864
+ checkNotReported (prepareNetworkExceptionSocketException);
865
+ });
852
866
});
853
867
});
854
868
0 commit comments