CI: Fix golangci-lint linter issues, add prealloc linter and bump version depends for Go 1.18 (#915)

* Bump CI versions

* Specifically set go version as 1.17.x bumps it to 1.18

* Another

* Adjust AppVeyor

* Part 1 of linter issues

* Part 2

* Fix various linters and improvements

* Part 3

* Finishing touches

* Tests and EqualFold

* Fix nitterinos plus bonus requester jobs bump for exchanges with large number of tests

* Fix nitterinos and bump golangci-lint timeout for AppVeyor

* Address nits, ensure all books are returned on err due to syncer regression

* Fix the wiggins

* Fix duplication

* Fix nitterinos
This commit is contained in:
Adrian Gallagher
2022-04-20 13:45:15 +10:00
committed by GitHub
parent c48e5ea90a
commit 9a4eb9de84
216 changed files with 3493 additions and 2424 deletions

View File

@@ -2,6 +2,8 @@ package cache
import (
"testing"
"github.com/thrasher-corp/gocryptotrader/common/convert"
)
func TestCache(t *testing.T) {
@@ -16,12 +18,11 @@ func TestCache(t *testing.T) {
if v == nil {
t.Fatal("expected cache to contain \"hello\" key")
}
if v.(string) != "world" {
if convert.InterfaceToStringOrZeroValue(v) != "world" {
t.Fatal("expected \"hello\" key to contain value \"world\"")
}
r := lruCache.Remove("hello")
if !r {
if r := lruCache.Remove("hello"); !r {
t.Fatal("expected \"hello\" key to be removed from cache")
}
@@ -77,39 +78,39 @@ func TestAdd(t *testing.T) {
if v == nil {
t.Fatal("expected cache to contain \"2\" key")
}
if v.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(v) != 2 {
t.Fatal("expected \"2\" key to contain value \"2\"")
}
k, v := lruCache.getNewest()
if k.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(k) != 2 {
t.Fatal("expected latest key to be 2")
}
if v.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(v) != 2 {
t.Fatal("expected latest value to be 2")
}
lruCache.Add(3, 3)
k, _ = lruCache.getNewest()
if k.(int) != 3 {
if convert.InterfaceToIntOrZeroValue(k) != 3 {
t.Fatal("expected latest key to be 3")
}
k, _ = lruCache.getOldest()
if k.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(k) != 2 {
t.Fatal("expected oldest key to be 2")
}
k, v = lruCache.getOldest()
if k.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(k) != 2 {
t.Fatal("expected oldest key to be 2")
}
if v.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(v) != 2 {
t.Fatal("expected latest value to be 2")
}
lruCache.Add(2, 2)
k, _ = lruCache.getNewest()
if k.(int) != 2 {
if convert.InterfaceToIntOrZeroValue(k) != 2 {
t.Fatal("expected latest key to be 2")
}
k, _ = lruCache.getOldest()
if k.(int) != 3 {
if convert.InterfaceToIntOrZeroValue(k) != 3 {
t.Fatal("expected oldest key to be 3")
}
}