videoconf/app_test.go

43 lines
838 B
Go
Raw Normal View History

2016-02-29 20:16:20 +01:00
package main
import (
. "github.com/franela/goblin"
2016-02-29 20:29:47 +01:00
"github.com/gin-gonic/gin"
2016-02-29 20:16:20 +01:00
"net/http"
"net/http/httptest"
"testing"
)
func performRequest(method, path string) *httptest.ResponseRecorder {
2016-02-29 20:29:47 +01:00
gin.SetMode("test")
app := NewApp()
req, _ := http.NewRequest(method, path, nil)
2016-02-29 20:16:20 +01:00
w := httptest.NewRecorder()
app.ServeHTTP(w, req)
return w
}
func Test(t *testing.T) {
g := Goblin(t)
g.Describe("App api", func() {
g.It("Should return 200 on / ", func() {
2016-02-29 20:29:47 +01:00
w := performRequest("GET", "/")
2016-02-29 20:16:20 +01:00
g.Assert(w.Code).Equal(200)
})
g.It("Should return 200 on /slides.md ", func() {
2016-02-29 20:29:47 +01:00
w := performRequest("GET", "/slides.md")
2016-02-29 20:16:20 +01:00
g.Assert(w.Code).Equal(200)
})
g.It("Should return 200 on PUT /slides.md ", func() {
2016-02-29 20:29:47 +01:00
w := performRequest("PUT", "/slides.md")
2016-02-29 20:16:20 +01:00
g.Assert(w.Code).Equal(200)
})
g.It("Should works")
})
}