genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/http/good_test.go

36 lines
794 B
Go
Raw Normal View History

package http
import (
"net/http"
"testing"
"github.com/genofire/hs_master-kss-monolith/lib/database"
2017-03-30 19:05:33 +02:00
"github.com/genofire/hs_master-kss-monolith/models"
"github.com/genofire/hs_master-kss-monolith/test"
)
func TestGood(t *testing.T) {
assertion, router := test.Init(t)
2017-03-30 19:05:33 +02:00
BindAPI(router)
session := test.NewSession(router)
result, w := session.JSONRequest("GET", "/api/good/a", nil)
2017-03-30 19:05:33 +02:00
assertion.Equal(http.StatusNotAcceptable, w.StatusCode)
result, w = session.JSONRequest("GET", "/api/good/1", nil)
2017-03-30 19:05:33 +02:00
assertion.Equal(http.StatusNotFound, w.StatusCode)
database.Write.Create(&models.Good{
ProductID: 3,
Comment: "blub",
2017-03-30 19:05:33 +02:00
})
result, w = session.JSONRequest("GET", "/api/good/3", nil)
assertion.Equal(http.StatusOK, w.StatusCode)
2017-03-30 19:05:33 +02:00
assertion.Len(result, 1)
test.Close()
}