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/review_test.go

39 lines
875 B
Go

package http
import (
"net/http"
"testing"
"github.com/genofire/hs_master-kss-monolith/lib/database"
"github.com/genofire/hs_master-kss-monolith/models"
"github.com/genofire/hs_master-kss-monolith/test"
)
func TestReview(t *testing.T) {
assertion, router := test.Init(t)
BindAPI(router)
session := test.NewSession(router)
result, w := session.JSONRequest("GET", "/api/review/a", nil)
assertion.Equal(http.StatusNotAcceptable, w.StatusCode)
result, w = session.JSONRequest("GET", "/api/review/1", nil)
assertion.Equal(http.StatusNotFound, w.StatusCode)
database.Write.Create(&models.Review{
ProductID: 3,
FirstName: "Max",
LastName: "Mustmann",
RatingStars: 3,
Text: "blub",
})
result, w = session.JSONRequest("GET", "/api/review/3", nil)
assertion.Equal(http.StatusOK, w.StatusCode)
assertion.Len(result, 1)
test.Close()
}