From 87d601a62c56e35cdbe9075f5b5e0a4f3d73fe8d Mon Sep 17 00:00:00 2001 From: haider Date: Wed, 8 Feb 2023 14:33:29 +0000 Subject: [PATCH] Pipeline fix --- lib/data/network/currency_api.dart | 2 +- lib/data/network/safe_api_call.dart | 6 +++--- test/resources/success_call_api.json | 14 ++++---------- test/unit_test/repository_test.dart | 8 ++++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/data/network/currency_api.dart b/lib/data/network/currency_api.dart index 3fc69b1..3fbe42b 100644 --- a/lib/data/network/currency_api.dart +++ b/lib/data/network/currency_api.dart @@ -30,7 +30,7 @@ abstract class CurrencyApi { @JsonSerializable() class ResponseObject implements CurrencyMapper { String base; - String last_updated; + int last_updated; Map? exchange_rates; ResponseObject(this.base, this.last_updated, this.exchange_rates); diff --git a/lib/data/network/safe_api_call.dart b/lib/data/network/safe_api_call.dart index 73647a9..d008140 100644 --- a/lib/data/network/safe_api_call.dart +++ b/lib/data/network/safe_api_call.dart @@ -15,14 +15,14 @@ mixin SafeApiCall { Map? errorResponse = dioError.response?.data?["error"]; String error; - if (errorResponse?["error"] != null){ - error = errorResponse!["error"]; + if (errorResponse?["message"] != null){ + error = errorResponse!["message"]; } else if (dioError.error != null){ error = dioError.error; } else { error = "Failed to retrieve data from api"; } - logger.e(dioError.error); + logger.e(error); throw HttpException(error); } diff --git a/test/resources/success_call_api.json b/test/resources/success_call_api.json index aff2cb9..7bd5fd7 100644 --- a/test/resources/success_call_api.json +++ b/test/resources/success_call_api.json @@ -1,13 +1,7 @@ { - "query": { - "count": 1 - }, - "results": { - "AUD_GBP": { - "id": "AUD_GBP", - "fr": "AUD", - "to": "GBP", - "val": 0.601188 - } + "base": "AUD", + "last_updated": 1675689300, + "exchange_rates": { + "GBP": 0.601188 } } \ No newline at end of file diff --git a/test/unit_test/repository_test.dart b/test/unit_test/repository_test.dart index fc812c3..2c8be75 100644 --- a/test/unit_test/repository_test.dart +++ b/test/unit_test/repository_test.dart @@ -108,9 +108,9 @@ void main() { .thenAnswer((_) async => Future.error(backUpError)); // Then - expect(() async => await sut.getConversationRateFromApi(fromCurrency, toCurrency), - throwsA(predicate((e) => - e is HttpException && - e.message == 'Error message'))); + expect(() async => + await sut.getConversationRateFromApi(fromCurrency, toCurrency), + throwsA(predicate( + (e) => e is HttpException && e.message == 'Error message'))); }); }