mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-28 07:51:28 +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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@ 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"},
|
||||||
|
@ -57,7 +56,6 @@ var (
|
||||||
{"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