32 lines
621 B
Go
Raw Normal View History

2017-06-22 16:08:34 +02:00
package main
import (
2017-10-16 01:07:08 +02:00
"fmt"
2017-06-22 16:08:34 +02:00
"net/http"
"net/http/httptest"
"testing"
"github.com/aerogo/aero"
)
func TestRoutes(t *testing.T) {
app := configure(aero.New())
2017-07-02 17:51:17 +02:00
for _, examples := range routeTests {
2017-06-25 12:05:32 +02:00
for _, example := range examples {
request, err := http.NewRequest("GET", example, nil)
if err != nil {
t.Fatal(err)
}
2017-06-22 16:08:34 +02:00
2017-06-25 12:05:32 +02:00
responseRecorder := httptest.NewRecorder()
app.Handler().ServeHTTP(responseRecorder, request)
2017-06-22 16:08:34 +02:00
2017-06-25 12:05:32 +02:00
if status := responseRecorder.Code; status != http.StatusOK {
2017-10-16 01:07:08 +02:00
panic(fmt.Errorf("%s | Wrong status code | %v instead of %v", example, status, http.StatusOK))
2017-10-02 00:31:44 +02:00
}
}
}
}