notes-server/server/routes_test.go

39 lines
617 B
Go

package server
import (
"net/http"
"net/http/httptest"
"net/url"
"testing"
)
func TestServerRoutes(t *testing.T) {
s := New()
err := s.Routes()
if err != nil {
t.Fatal(err)
}
}
func TestServerNotes(t *testing.T) {
s := New()
w := httptest.NewRecorder()
r := &http.Request{
URL: &url.URL{
Path: "/",
},
}
s.notes(w, r)
t.Logf("serve %s: %s", r.URL.Path, w.Body.Bytes())
w.Body.Reset()
r.URL.Path = "/serve/"
s.notes(w, r)
t.Logf("serve %s: %s", r.URL.Path, w.Body.Bytes())
w.Body.Reset()
r.URL.Path = "/serve/test"
s.notes(w, r)
t.Logf("serve %s: %s", r.URL.Path, w.Body.Bytes())
}