go-http-peering/chi/mount_test.go

42 lines
938 B
Go

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"
"github.com/go-chi/chi"
)
func TestMount(t *testing.T) {
r := chi.NewRouter()
store := memory.NewStore()
pk, err := peeringCrypto.CreateRSAKey(1024)
if err != nil {
t.Fatal(err)
}
Mount(r, store, &pk.PublicKey)
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)
}
}