go-http-peering/chi/mount_test.go

42 lines
938 B
Go
Raw Permalink Normal View History

2019-02-03 20:56:58 +01:00
package chi
import (
"testing"
peering "forge.cadoles.com/Cadoles/go-http-peering"
peeringCrypto "forge.cadoles.com/Cadoles/go-http-peering/crypto"
"forge.cadoles.com/Cadoles/go-http-peering/memory"
2019-02-03 20:56:58 +01:00
"github.com/go-chi/chi"
)
func TestMount(t *testing.T) {
r := chi.NewRouter()
store := memory.NewStore()
2019-02-22 17:35:49 +01:00
pk, err := peeringCrypto.CreateRSAKey(1024)
if err != nil {
t.Fatal(err)
}
Mount(r, store, &pk.PublicKey)
2019-02-03 20:56:58 +01:00
routes := r.Routes()
if g, e := len(routes), 3; g != e {
t.Errorf("len(r.Routes()): got '%v', expected '%v'", g, e)
}
if g, e := routes[0].Pattern, peering.AdvertisePath; g != e {
t.Errorf("routes[0].Pattern: got '%v', expected '%v'", g, e)
}
if g, e := routes[1].Pattern, peering.PingPath; g != e {
t.Errorf("routes[1].Pattern: got '%v', expected '%v'", g, e)
}
if g, e := routes[2].Pattern, peering.UpdatePath; g != e {
t.Errorf("routes[2].Pattern: got '%v', expected '%v'", g, e)
}
}