mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-28 16:01:32 +00:00
Clean up tests a little
This commit is contained in:
parent
140a738162
commit
e8e692cbf6
3 changed files with 46 additions and 57 deletions
|
@ -35,10 +35,7 @@ func mapArrayEqual(boxed map[string][]string, unboxed map[string]string) bool {
|
||||||
}
|
}
|
||||||
for mapKey, mapVal := range boxed {
|
for mapKey, mapVal := range boxed {
|
||||||
// Always expect box to hold only one element
|
// Always expect box to hold only one element
|
||||||
if len(mapVal) != 1 {
|
if len(mapVal) != 1 || mapVal[0] != unboxed[mapKey] {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if ub_mapVal, eleExists := unboxed[mapKey]; !eleExists || mapVal[0] != ub_mapVal {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,10 +58,10 @@ func TestInvalidQueries(t *testing.T) {
|
||||||
for parseIndex, parseStr := range InvalidQueries {
|
for parseIndex, parseStr := range InvalidQueries {
|
||||||
parsedQueryObj, err := parseQuery(parseStr)
|
parsedQueryObj, err := parseQuery(parseStr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Should have produced error ", parseIndex)
|
t.Error("Should have produced error", parseIndex)
|
||||||
}
|
}
|
||||||
if parsedQueryObj != nil {
|
if parsedQueryObj != nil {
|
||||||
t.Error("Should be nil after error ", parsedQueryObj, parseIndex)
|
t.Error("Should be nil after error", parsedQueryObj, parseIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,51 +13,49 @@ type PeerClientPair struct {
|
||||||
clientId string
|
clientId string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var TestClients = []PeerClientPair{
|
||||||
TestClients = []PeerClientPair{
|
{"-AZ3034-6wfG2wk6wWLc", "AZ3034"},
|
||||||
{"-AZ3034-6wfG2wk6wWLc", "AZ3034"},
|
{"-AZ3042-6ozMq5q6Q3NX", "AZ3042"},
|
||||||
{"-AZ3042-6ozMq5q6Q3NX", "AZ3042"},
|
{"-BS5820-oy4La2MWGEFj", "BS5820"},
|
||||||
{"-BS5820-oy4La2MWGEFj", "BS5820"},
|
{"-AR6360-6oZyyMWoOOBe", "AR6360"},
|
||||||
{"-AR6360-6oZyyMWoOOBe", "AR6360"},
|
{"-AG2083-s1hiF8vGAAg0", "AG2083"},
|
||||||
{"-AG2083-s1hiF8vGAAg0", "AG2083"},
|
{"-AG3003-lEl2Mm4NEO4n", "AG3003"},
|
||||||
{"-AG3003-lEl2Mm4NEO4n", "AG3003"},
|
{"-MR1100-00HS~T7*65rm", "MR1100"},
|
||||||
{"-MR1100-00HS~T7*65rm", "MR1100"},
|
{"-LK0140-ATIV~nbEQAMr", "LK0140"},
|
||||||
{"-LK0140-ATIV~nbEQAMr", "LK0140"},
|
{"-KT2210-347143496631", "KT2210"},
|
||||||
{"-KT2210-347143496631", "KT2210"},
|
{"-TR0960-6ep6svaa61r4", "TR0960"},
|
||||||
{"-TR0960-6ep6svaa61r4", "TR0960"},
|
{"-XX1150-dv220cotgj4d", "XX1150"},
|
||||||
{"-XX1150-dv220cotgj4d", "XX1150"},
|
{"-AZ2504-192gwethivju", "AZ2504"},
|
||||||
{"-AZ2504-192gwethivju", "AZ2504"},
|
{"-KT4310-3L4UvarKuqIu", "KT4310"},
|
||||||
{"-KT4310-3L4UvarKuqIu", "KT4310"},
|
{"-AZ2060-0xJQ02d4309O", "AZ2060"},
|
||||||
{"-AZ2060-0xJQ02d4309O", "AZ2060"},
|
{"-BD0300-2nkdf08Jd890", "BD0300"},
|
||||||
{"-BD0300-2nkdf08Jd890", "BD0300"},
|
{"-A~0010-a9mn9DFkj39J", "A~0010"},
|
||||||
{"-A~0010-a9mn9DFkj39J", "A~0010"},
|
{"-UT2300-MNu93JKnm930", "UT2300"},
|
||||||
{"-UT2300-MNu93JKnm930", "UT2300"},
|
{"-UT2300-KT4310KT4301", "UT2300"},
|
||||||
{"-UT2300-KT4310KT4301", "UT2300"},
|
|
||||||
|
|
||||||
{"T03A0----f089kjsdf6e", "T03A0-"},
|
{"T03A0----f089kjsdf6e", "T03A0-"},
|
||||||
{"S58B-----nKl34GoNb75", "S58B--"},
|
{"S58B-----nKl34GoNb75", "S58B--"},
|
||||||
{"M4-4-0--9aa757Efd5Bl", "M4-4-0"},
|
{"M4-4-0--9aa757Efd5Bl", "M4-4-0"},
|
||||||
|
|
||||||
{"AZ2500BTeYUzyabAfo6U", "AZ2500"}, // BitTyrant
|
{"AZ2500BTeYUzyabAfo6U", "AZ2500"}, // BitTyrant
|
||||||
{"exbc0JdSklm834kj9Udf", "exbc0J"}, // Old BitComet
|
{"exbc0JdSklm834kj9Udf", "exbc0J"}, // Old BitComet
|
||||||
{"FUTB0L84j542mVc84jkd", "FUTB0L"}, // Alt BitComet
|
{"FUTB0L84j542mVc84jkd", "FUTB0L"}, // Alt BitComet
|
||||||
{"XBT054d-8602Jn83NnF9", "XBT054"}, // XBT
|
{"XBT054d-8602Jn83NnF9", "XBT054"}, // XBT
|
||||||
{"OP1011affbecbfabeefb", "OP1011"}, // Opera
|
{"OP1011affbecbfabeefb", "OP1011"}, // Opera
|
||||||
{"-ML2.7.2-kgjjfkd9762", "ML2.7."}, // MLDonkey
|
{"-ML2.7.2-kgjjfkd9762", "ML2.7."}, // MLDonkey
|
||||||
{"-BOWA0C-SDLFJWEIORNM", "BOWA0C"}, // Bits on Wheels
|
{"-BOWA0C-SDLFJWEIORNM", "BOWA0C"}, // Bits on Wheels
|
||||||
{"Q1-0-0--dsn34DFn9083", "Q1-0-0"}, // Queen Bee
|
{"Q1-0-0--dsn34DFn9083", "Q1-0-0"}, // Queen Bee
|
||||||
{"Q1-10-0-Yoiumn39BDfO", "Q1-10-"}, // Queen Bee Alt
|
{"Q1-10-0-Yoiumn39BDfO", "Q1-10-"}, // Queen Bee Alt
|
||||||
{"346------SDFknl33408", "346---"}, // TorreTopia
|
{"346------SDFknl33408", "346---"}, // TorreTopia
|
||||||
{"QVOD0054ABFFEDCCDEDB", "QVOD00"}, // Qvod
|
{"QVOD0054ABFFEDCCDEDB", "QVOD00"}, // Qvod
|
||||||
|
|
||||||
{"", ""},
|
{"", ""},
|
||||||
{"-", ""},
|
{"-", ""},
|
||||||
{"12345", ""},
|
{"12345", ""},
|
||||||
{"-12345", ""},
|
{"-12345", ""},
|
||||||
{"123456", "123456"},
|
{"123456", "123456"},
|
||||||
{"-123456", "123456"},
|
{"-123456", "123456"},
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
func TestParseClientID(t *testing.T) {
|
func TestParseClientID(t *testing.T) {
|
||||||
for _, pair := range TestClients {
|
for _, pair := range TestClients {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -16,12 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestServer() (*Server, error) {
|
func newTestServer() (*Server, error) {
|
||||||
s, err := New(&config.MockConfig)
|
return New(&config.MockConfig)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStats(t *testing.T) {
|
func TestStats(t *testing.T) {
|
||||||
|
@ -39,10 +33,10 @@ func TestStats(t *testing.T) {
|
||||||
s.serveStats(w, r)
|
s.serveStats(w, r)
|
||||||
|
|
||||||
if w.Code != 200 {
|
if w.Code != 200 {
|
||||||
t.Error(errors.New("/stats did not return HTTP 200"))
|
t.Error("/stats did not return 200 OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.Header()["Content-Type"][0] != "application/json" {
|
if w.Header()["Content-Type"][0] != "application/json" {
|
||||||
t.Error(errors.New("/stats did not return the proper Content-Type header"))
|
t.Error("/stats did not return JSON")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue