Skip to content

Commit

Permalink
order currencies in call to remove test flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyBuisset committed Dec 22, 2023
1 parent 88e880b commit 327407d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"request": {
"url": "/v2/cryptocurrency/quotes/latest?id=1027%2C11840%2C21794%2C17445%2C3408&convert=USD",
"url": "/v2/cryptocurrency/quotes/latest?id=1027%2C11840%2C17445%2C21794%2C3408&convert=USD",
"method": "GET",
"headers": {
"X-CMC_PRO_API_KEY": {
Expand Down
13 changes: 10 additions & 3 deletions common/infrastructure/src/coinmarketcap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,23 @@ impl Client {
&self,
currencies: Vec<String>,
) -> Result<Vec<quotes::Currency>> {
let currencies = self.get_currencies_ids(&currencies)?;
let currency_mapping: HashMap<String, String> = currencies
.clone()
.into_iter()
.zip(self.get_currencies_ids(&currencies)?.into_iter())
.collect();

let mut currency_ids: Vec<_> = currency_mapping.values().cloned().collect();
currency_ids.sort();

Check warning on line 58 in common/infrastructure/src/coinmarketcap/mod.rs

View check run for this annotation

Codecov / codecov/patch

common/infrastructure/src/coinmarketcap/mod.rs#L51-L58

Added lines #L51 - L58 were not covered by tests

let response = self.client.quotes_latest_by_id(currencies.join(",")).await?;
let response = self.client.quotes_latest_by_id(currency_ids.join(",")).await?;

Check warning on line 60 in common/infrastructure/src/coinmarketcap/mod.rs

View check run for this annotation

Codecov / codecov/patch

common/infrastructure/src/coinmarketcap/mod.rs#L60

Added line #L60 was not covered by tests

currencies
.into_iter()
.map(|currency| {
response
.data
.get(&currency)
.get(currency_mapping.get(&currency).unwrap())

Check warning on line 67 in common/infrastructure/src/coinmarketcap/mod.rs

View check run for this annotation

Codecov / codecov/patch

common/infrastructure/src/coinmarketcap/mod.rs#L67

Added line #L67 was not covered by tests
.and_then(|currency| currency.quote.get(currencies::USD.code).cloned())
.ok_or_else(|| Error::NotFound(currency.to_owned()))
})
Expand Down

0 comments on commit 327407d

Please sign in to comment.