TF-4136 Remove all content-length in header request of mock unit test avoid run test fail

This commit is contained in:
dab246
2025-12-15 12:01:59 +07:00
committed by Dat H. Pham
parent fbf2533f3e
commit fdda936ac2
15 changed files with 17 additions and 30 deletions
@@ -41,14 +41,14 @@ void main() {
const responseStatusCode500 = 500;
const responseStatusCode200 = 200;
final dioError401 = DioError(
final dioError401 = DioException(
error: {'message': 'Token Expired'},
requestOptions: RequestOptions(path: baseUrl, method: 'POST'),
response: Response(
statusCode: responseStatusCode401,
requestOptions: RequestOptions(path: baseUrl)
),
type: DioErrorType.badResponse,
type: DioExceptionType.badResponse,
);
final dataRequestSuccessfully = {'message': 'Request successfully!'};
@@ -240,24 +240,24 @@ void main() {
expect(
() async => await dio.post(baseUrl),
throwsA(predicate<DioError>((error) => error.response?.statusCode == responseStatusCode401))
throwsA(predicate<DioException>((error) => error.response?.statusCode == responseStatusCode401))
);
});
});
});
group('AuthorizationInterceptor: multiple requests queued on onError', () {
final requestOneDioError401 = DioError(
final requestOneDioError401 = DioException(
error: {'message': 'Token Expired'},
requestOptions: RequestOptions(path: '$baseUrl/1', method: 'POST'),
response: Response(
statusCode: responseStatusCode401,
requestOptions: RequestOptions(path: '$baseUrl/1')
),
type: DioErrorType.badResponse,
type: DioExceptionType.badResponse,
);
final requestTwoDioError401 = DioError(
final requestTwoDioError401 = DioException(
error: {'message': 'Token Expired'},
requestOptions: RequestOptions(
path: '$baseUrl/2',
@@ -268,7 +268,7 @@ void main() {
statusCode: responseStatusCode401,
requestOptions: RequestOptions(path: '$baseUrl/2')
),
type: DioErrorType.badResponse,
type: DioExceptionType.badResponse,
);
test('GIVEN 2 requests have token expired\n'
@@ -367,7 +367,7 @@ void main() {
dio.post('$baseUrl/1',),
dio.post('$baseUrl/2',)
]),
throwsA(predicate<DioError>(
throwsA(predicate<DioException>(
(dioError) => dioError.error is AccessTokenInvalidException))
);
@@ -20,11 +20,11 @@ void main() {
test(
'should throw CanNotFoundOIDCLinks '
'when checkOIDCIsAvailable() is called '
'and dioClient throw DioError '
'and dioClient throw DioException '
'and status code is 404',
() {
// arrange
when(dioClient.get(any)).thenThrow(DioError(
when(dioClient.get(any)).thenThrow(DioException(
requestOptions: requestOptions,
response: Response(requestOptions: requestOptions, statusCode: 404)));
@@ -37,11 +37,11 @@ void main() {
test(
'should throw CanRetryOIDCException '
'when checkOIDCIsAvailable() is called '
'and dioClient throw DioError '
'and dioClient throw DioException '
'and status code is not 404',
() {
// arrange
when(dioClient.get(any)).thenThrow(DioError(
when(dioClient.get(any)).thenThrow(DioException(
requestOptions: requestOptions,
response: Response(requestOptions: requestOptions, statusCode: 403)));
@@ -54,7 +54,7 @@ void main() {
test(
'should throw CanRetryOIDCException '
'when checkOIDCIsAvailable() is called '
'and dioClient throw exception that is not DioError',
'and dioClient throw exception that is not DioException',
() {
// arrange
when(dioClient.get(any)).thenThrow(Exception());
@@ -87,7 +87,6 @@ void main() {
},
headers: {
"accept": "application/json;jmapVersion=rfc-8621",
"content-length": 503
},
);
@@ -613,7 +613,7 @@ void main() {
propertiesCreated: defaultCreatedProperties,
propertiesUpdated: defaultUpdatedProperties,
),
headers: dioAdapterHeaders..addAll({'content-length': 1245}),
headers: dioAdapterHeaders,
);
// act
@@ -662,7 +662,7 @@ void main() {
propertiesCreated: defaultCreatedProperties,
propertiesUpdated: defaultUpdatedProperties,
),
headers: dioAdapterHeaders..addAll({'content-length': 1245}),
headers: dioAdapterHeaders
);
// act
@@ -714,7 +714,7 @@ void main() {
data: generateRequest(
propertiesCreated: defaultCreatedProperties,
),
headers: dioAdapterHeaders..addAll({'content-length': 798}),
headers: dioAdapterHeaders
);
// act
@@ -752,7 +752,7 @@ void main() {
generateResponse(),
),
data: generateRequest(),
headers: dioAdapterHeaders..addAll({'content-length': 355}),
headers: dioAdapterHeaders
);
// act