mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add support for Function and Trigger domain objects (#1060)
Vast commit, includes: * Introduces the Trigger domain entity. * Introduces the Fns domain entity. * V2 of the API for interacting with the new entities in swaggerv2.yml * Adds v2 end points for Apps to support PUT updates. * Rewrites the datastore level tests into a new pattern. * V2 routes use entity ID over name as the path parameter.
This commit is contained in:
@@ -86,6 +86,15 @@ func newRouterRequest(t *testing.T, method, path string, body io.Reader) (*http.
|
||||
return req, rec
|
||||
}
|
||||
|
||||
func getV1ErrorResponse(t *testing.T, rec *httptest.ResponseRecorder) *models.ErrorWrapper {
|
||||
var err models.ErrorWrapper
|
||||
decodeErr := json.NewDecoder(rec.Body).Decode(&err)
|
||||
if decodeErr != nil {
|
||||
t.Error("Test: Expected not empty response body")
|
||||
}
|
||||
return &err
|
||||
}
|
||||
|
||||
func getErrorResponse(t *testing.T, rec *httptest.ResponseRecorder) *models.Error {
|
||||
var err models.Error
|
||||
decodeErr := json.NewDecoder(rec.Body).Decode(&err)
|
||||
@@ -150,14 +159,17 @@ func TestFullStack(t *testing.T) {
|
||||
{"get deleted app", "GET", "/v1/apps/myapp", ``, http.StatusNotFound, 0},
|
||||
{"get deleteds route on deleted app", "GET", "/v1/apps/myapp/routes/myroute", ``, http.StatusNotFound, 0},
|
||||
} {
|
||||
_, rec := routerRequest(t, srv.Router, test.method, test.path, bytes.NewBuffer([]byte(test.body)))
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, rec := routerRequest(t, srv.Router, test.method, test.path, bytes.NewBuffer([]byte(test.body)))
|
||||
|
||||
if rec.Code != test.expectedCode {
|
||||
t.Log(buf.String())
|
||||
t.Log(rec.Body.String())
|
||||
t.Errorf("Test \"%s\": Expected status code to be %d but was %d",
|
||||
test.name, test.expectedCode, rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
if rec.Code != test.expectedCode {
|
||||
t.Log(buf.String())
|
||||
t.Log(rec.Body.String())
|
||||
t.Errorf("Test \"%s\": Expected status code to be %d but was %d",
|
||||
test.name, test.expectedCode, rec.Code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,8 +280,7 @@ func TestApiNode(t *testing.T) {
|
||||
|
||||
func TestHybridEndpoints(t *testing.T) {
|
||||
buf := setLogBuffer()
|
||||
app := &models.App{Name: "myapp"}
|
||||
app.SetDefaults()
|
||||
app := &models.App{ID: "app_id", Name: "myapp"}
|
||||
ds := datastore.NewMockInit(
|
||||
[]*models.App{app},
|
||||
[]*models.Route{{
|
||||
|
||||
Reference in New Issue
Block a user