mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-23 17:47:29 +00:00
Remove unnecessary test indirection
This commit is contained in:
parent
586b6852de
commit
f20fea7db0
1 changed files with 58 additions and 74 deletions
|
@ -14,47 +14,33 @@ import (
|
||||||
|
|
||||||
"github.com/chihaya/bencode"
|
"github.com/chihaya/bencode"
|
||||||
"github.com/chihaya/chihaya/config"
|
"github.com/chihaya/chihaya/config"
|
||||||
"github.com/chihaya/chihaya/drivers/backend"
|
|
||||||
"github.com/chihaya/chihaya/drivers/tracker"
|
|
||||||
"github.com/chihaya/chihaya/models"
|
"github.com/chihaya/chihaya/models"
|
||||||
|
|
||||||
_ "github.com/chihaya/chihaya/drivers/backend/noop"
|
_ "github.com/chihaya/chihaya/drivers/backend/noop"
|
||||||
_ "github.com/chihaya/chihaya/drivers/tracker/memory"
|
_ "github.com/chihaya/chihaya/drivers/tracker/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
type primer func(tracker.Pool, backend.Conn) error
|
|
||||||
|
|
||||||
func (t *Tracker) prime(p primer) error {
|
|
||||||
return p(t.tp, t.bc)
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadTestData(tkr *Tracker) (err error) {
|
func loadTestData(tkr *Tracker) (err error) {
|
||||||
return tkr.prime(func(tp tracker.Pool, bc backend.Conn) (err error) {
|
conn, err := tkr.tp.Get()
|
||||||
conn, err := tp.Get()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users := []string{
|
||||||
|
"yby47f04riwpndba456rqxtmifenqxx1",
|
||||||
|
"yby47f04riwpndba456rqxtmifenqxx2",
|
||||||
|
"yby47f04riwpndba456rqxtmifenqxx3",
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, passkey := range users {
|
||||||
err = conn.PutUser(&models.User{
|
err = conn.PutUser(&models.User{
|
||||||
ID: 1,
|
ID: uint64(i + 1),
|
||||||
Passkey: "yby47f04riwpndba456rqxtmifenqxx1",
|
Passkey: passkey,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.PutUser(&models.User{
|
|
||||||
ID: 2,
|
|
||||||
Passkey: "yby47f04riwpndba456rqxtmifenqxx2",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = conn.PutUser(&models.User{
|
|
||||||
ID: 3,
|
|
||||||
Passkey: "yby47f04riwpndba456rqxtmifenqxx3",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = conn.PutClient("TR2820")
|
err = conn.PutClient("TR2820")
|
||||||
|
@ -94,9 +80,7 @@ func loadTestData(tkr *Tracker) (err error) {
|
||||||
Port: 34000,
|
Port: 34000,
|
||||||
Left: 0,
|
Left: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRoute(cfg *config.Config, url string) ([]byte, error) {
|
func testRoute(cfg *config.Config, url string) ([]byte, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue