diff --git a/pkg/exchangerates/bank_of_canada_datasource_test.go b/pkg/exchangerates/bank_of_canada_datasource_test.go
index 9c9c4327..8f9a0b04 100644
--- a/pkg/exchangerates/bank_of_canada_datasource_test.go
+++ b/pkg/exchangerates/bank_of_canada_datasource_test.go
@@ -181,4 +181,17 @@ func TestBankOfCanadaDataSource_InvalidRate(t *testing.T) {
"}"))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+
+ actualLatestExchangeRateResponse, err = dataSource.Parse(context, []byte("{"+
+ " \"observations\": [\n"+
+ " {\n"+
+ " \"d\": \"2021-04-01\",\n"+
+ " \"FXUSDCAD\": {\n"+
+ " \"v\": \"0\"\n"+
+ " }\n"+
+ " }\n"+
+ " ]\n"+
+ "}"))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
}
diff --git a/pkg/exchangerates/international_monetary_fund_datasource_test.go b/pkg/exchangerates/international_monetary_fund_datasource_test.go
index 6ba15c54..4d4aa88d 100644
--- a/pkg/exchangerates/international_monetary_fund_datasource_test.go
+++ b/pkg/exchangerates/international_monetary_fund_datasource_test.go
@@ -104,6 +104,20 @@ func TestInternationalMonetaryFundDataSource_MissingDefaultCurrencyData(t *testi
assert.NotEqual(t, nil, err)
}
+func TestInternationalMonetaryFundDataSource_DefaultCurrencyDataInvalid(t *testing.T) {
+ dataSource := &InternationalMonetaryFundDataSource{}
+ context := core.NewNullContext()
+
+ _, err := dataSource.Parse(context, []byte("SDRs per Currency unit and Currency units per SDR (1)\n"+
+ "last five days\n"+
+ "SDRs per Currency unit (2)\n"+
+ "\n"+
+ "Currency\tAugust 28, 2024\tAugust 27, 2024\tAugust 26, 2024\tAugust 23, 2024\tAugust 22, 2024\n"+
+ "Chinese yuan\t0.1040520000\t0.1039250000\t0.1040370000\t0.1040850000\t0.1040570000\n"+
+ "U.S. dollar\t0\t0\t0\t0\t0\n"))
+ assert.NotEqual(t, nil, err)
+}
+
func TestInternationalMonetaryFundDataSource_InvalidCurrency(t *testing.T) {
dataSource := &InternationalMonetaryFundDataSource{}
context := core.NewNullContext()
@@ -119,6 +133,41 @@ func TestInternationalMonetaryFundDataSource_InvalidCurrency(t *testing.T) {
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 1)
}
+func TestInternationalMonetaryFundDataSource_InvalidRate(t *testing.T) {
+ dataSource := &InternationalMonetaryFundDataSource{}
+ context := core.NewNullContext()
+
+ actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("SDRs per Currency unit and Currency units per SDR (1)\n"+
+ "last five days\n"+
+ "SDRs per Currency unit (2)\n"+
+ "\n"+
+ "Currency\tAugust 28, 2024\tAugust 27, 2024\tAugust 26, 2024\tAugust 23, 2024\tAugust 22, 2024\n"+
+ "Chinese yuan\tnull\tnull\tnull\tnull\tnull\n"+
+ "U.S. dollar\t0.7417320000\t0.7410250000\t0.7408270000\t0.7429280000\t0.7423020000\n"))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 1)
+
+ actualLatestExchangeRateResponse, err = dataSource.Parse(context, []byte("SDRs per Currency unit and Currency units per SDR (1)\n"+
+ "last five days\n"+
+ "SDRs per Currency unit (2)\n"+
+ "\n"+
+ "Currency\tAugust 28, 2024\tAugust 27, 2024\tAugust 26, 2024\tAugust 23, 2024\tAugust 22, 2024\n"+
+ "Chinese yuan\t0\t0\t0\t0\t0\n"+
+ "U.S. dollar\t0.7417320000\t0.7410250000\t0.7408270000\t0.7429280000\t0.7423020000\n"))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 1)
+
+ actualLatestExchangeRateResponse, err = dataSource.Parse(context, []byte("SDRs per Currency unit and Currency units per SDR (1)\n"+
+ "last five days\n"+
+ "SDRs per Currency unit (2)\n"+
+ "\n"+
+ "Currency\tAugust 28, 2024\tAugust 27, 2024\tAugust 26, 2024\tAugust 23, 2024\tAugust 22, 2024\n"+
+ "Chinese yuan\t\t\t\t\t\n"+
+ "U.S. dollar\t0.7417320000\t0.7410250000\t0.7408270000\t0.7429280000\t0.7423020000\n"))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 1)
+}
+
func TestInternationalMonetaryFundDataSource_LatestDateNotHasRate(t *testing.T) {
dataSource := &InternationalMonetaryFundDataSource{}
context := core.NewNullContext()
diff --git a/pkg/exchangerates/national_bank_of_poland_datasource_test.go b/pkg/exchangerates/national_bank_of_poland_datasource_test.go
index a391f8d4..8b106d04 100644
--- a/pkg/exchangerates/national_bank_of_poland_datasource_test.go
+++ b/pkg/exchangerates/national_bank_of_poland_datasource_test.go
@@ -171,4 +171,19 @@ func TestNationalBankOfPolandDataSource_InvalidRate(t *testing.T) {
""))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+
+ actualLatestExchangeRateResponse, err = dataSource.Parse(context, []byte("\n"+
+ "\n"+
+ " \n"+
+ " 2024-02-28\n"+
+ " \n"+
+ " \n"+
+ " USD\n"+
+ " 0\n"+
+ " \n"+
+ " \n"+
+ " \n"+
+ ""))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
}
diff --git a/pkg/exchangerates/swiss_national_bank_datasource_test.go b/pkg/exchangerates/swiss_national_bank_datasource_test.go
index 35ae8cbd..5c585413 100644
--- a/pkg/exchangerates/swiss_national_bank_datasource_test.go
+++ b/pkg/exchangerates/swiss_national_bank_datasource_test.go
@@ -330,4 +330,59 @@ func TestSwissNationalBankDataSource_InvalidRate(t *testing.T) {
""))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+
+ actualLatestExchangeRateResponse, err = dataSource.Parse(context, []byte("\n"+
+ "\n"+
+ " \n"+
+ " Tue, 12 Nov 2024 11:00:50 GMT\n"+
+ " - \n"+
+ " \n"+
+ " \n"+
+ " \n"+
+ " 0\n"+
+ " CHF\n"+
+ " 1\n"+
+ " \n"+
+ " CHF\n"+
+ " EUR\n"+
+ " \n"+
+ " 2024-11-12\n"+
+ " \n"+
+ " \n"+
+ " \n"+
+ "
\n"+
+ " \n"+
+ ""))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+}
+
+func TestSwissNationalBankDataSource_InvalidUnit(t *testing.T) {
+ dataSource := &SwissNationalBankDataSource{}
+ context := core.NewNullContext()
+
+ actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("\n"+
+ "\n"+
+ " \n"+
+ " Tue, 12 Nov 2024 11:00:50 GMT\n"+
+ " - \n"+
+ " \n"+
+ " \n"+
+ " \n"+
+ " 0.9378\n"+
+ " CHF\n"+
+ " null\n"+
+ " \n"+
+ " CHF\n"+
+ " EUR\n"+
+ " \n"+
+ " 2024-11-12\n"+
+ " \n"+
+ " \n"+
+ " \n"+
+ "
\n"+
+ " \n"+
+ ""))
+ assert.Equal(t, nil, err)
+ assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
}