mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 07:26:48 +00:00
Migrate from gometalinter.v2 to golangci-lint (#249)
* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
// Const values for the ticker package
|
||||
const (
|
||||
ErrTickerForExchangeNotFound = "Ticker for exchange does not exist."
|
||||
ErrPrimaryCurrencyNotFound = "Error primary currency for ticker not found."
|
||||
ErrSecondaryCurrencyNotFound = "Error secondary currency for ticker not found."
|
||||
ErrTickerForExchangeNotFound = "ticker for exchange does not exist"
|
||||
ErrPrimaryCurrencyNotFound = "primary currency for ticker not found"
|
||||
ErrSecondaryCurrencyNotFound = "secondary currency for ticker not found"
|
||||
|
||||
Spot = "SPOT"
|
||||
)
|
||||
@@ -91,9 +91,9 @@ func GetTicker(exchange string, p pair.CurrencyPair, tickerType string) (Price,
|
||||
func GetTickerByExchange(exchange string) (*Ticker, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
for _, y := range Tickers {
|
||||
if y.ExchangeName == exchange {
|
||||
return &y, nil
|
||||
for x := range Tickers {
|
||||
if Tickers[x].ExchangeName == exchange {
|
||||
return &Tickers[x], nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New(ErrTickerForExchangeNotFound)
|
||||
|
||||
@@ -200,6 +200,7 @@ func TestCreateNewTicker(t *testing.T) {
|
||||
}
|
||||
|
||||
newTicker := CreateNewTicker("ANX", newPair, priceStruct, Spot)
|
||||
const float64Type = "float64"
|
||||
|
||||
if reflect.ValueOf(newTicker).NumField() != 2 {
|
||||
t.Error("Test Failed - ticker CreateNewTicker struct change/or updated")
|
||||
@@ -214,33 +215,33 @@ func TestCreateNewTicker(t *testing.T) {
|
||||
if newTicker.Price["BTC"]["USD"][Spot].Pair.Pair().String() != "BTCUSD" {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Pair.Pair().String() value is not expected 'BTCUSD'")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Ask).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Ask).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Ask value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Bid).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Bid).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Bid value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].CurrencyPair).String() != "string" {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].CurrencyPair value is not a string")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].High).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].High).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].High value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Last).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Last).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Last value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Low).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Low).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Low value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].PriceATH).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].PriceATH).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].PriceATH value is not a float64")
|
||||
}
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Volume).String() != "float64" {
|
||||
if reflect.TypeOf(newTicker.Price["BTC"]["USD"][Spot].Volume).String() != float64Type {
|
||||
t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Volume value is not a float64")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessTicker(t *testing.T) { //non-appending function to tickers
|
||||
func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
Tickers = []Ticker{}
|
||||
newPair := pair.NewCurrencyPair("BTC", "USD")
|
||||
priceStruct := Price{
|
||||
@@ -317,10 +318,12 @@ func TestProcessTicker(t *testing.T) { //non-appending function to tickers
|
||||
|
||||
for _, test := range testArray {
|
||||
wg.Add(1)
|
||||
fatalErr := false
|
||||
go func(test quick) {
|
||||
result, err := GetTicker(test.Name, test.P, Spot)
|
||||
if err != nil {
|
||||
t.Fatal("Test failed. TestProcessTicker failed to retrieve new ticker")
|
||||
fatalErr = true
|
||||
return
|
||||
}
|
||||
|
||||
if result.Last != test.TP.Last {
|
||||
@@ -329,6 +332,10 @@ func TestProcessTicker(t *testing.T) { //non-appending function to tickers
|
||||
|
||||
wg.Done()
|
||||
}(test)
|
||||
|
||||
if fatalErr {
|
||||
t.Fatal("Test failed. TestProcessTicker failed to retrieve new ticker")
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user