code format

This commit is contained in:
MaysWind
2021-04-05 01:45:09 +08:00
parent 7b51584c7c
commit e34e55eac7
5 changed files with 38 additions and 38 deletions
@@ -8,8 +8,8 @@ import (
"github.com/mayswind/lab/pkg/errs" "github.com/mayswind/lab/pkg/errs"
"github.com/mayswind/lab/pkg/log" "github.com/mayswind/lab/pkg/log"
"github.com/mayswind/lab/pkg/models" "github.com/mayswind/lab/pkg/models"
"github.com/mayswind/lab/pkg/validators"
"github.com/mayswind/lab/pkg/utils" "github.com/mayswind/lab/pkg/utils"
"github.com/mayswind/lab/pkg/validators"
) )
const euroCentralBankExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml" const euroCentralBankExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
@@ -75,8 +75,8 @@ func TestEuroCentralBankDataSource_EmptyEnvelopeContent(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + _, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.NotEqual(t, nil, err) assert.NotEqual(t, nil, err)
} }
@@ -87,10 +87,10 @@ func TestEuroCentralBankDataSource_EmptyCubeContent(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + _, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.NotEqual(t, nil, err) assert.NotEqual(t, nil, err)
} }
@@ -101,13 +101,13 @@ func TestEuroCentralBankDataSource_InvalidCurrency(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"XXX\" rate=\"1\" />" + "<Cube currency=\"XXX\" rate=\"1\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -119,13 +119,13 @@ func TestEuroCentralBankDataSource_EmptyRate(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"\" />" + "<Cube currency=\"USD\" rate=\"\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -137,13 +137,13 @@ func TestEuroCentralBankDataSource_InvalidRate(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"null\" />" + "<Cube currency=\"USD\" rate=\"null\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)