-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/blocklessnetworking/b7s/models/response" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
// Execute implements the REST API endpoint for function execution. | ||
func (a *API) Health(ctx echo.Context) error { | ||
|
||
// respond with health check | ||
resp := response.Health{ | ||
Type: "health", | ||
Code: http.StatusOK, | ||
} | ||
|
||
// Send the response. | ||
return ctx.JSON(http.StatusOK, resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package api_test | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/blocklessnetworking/b7s/models/response" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAPI_HealthResult(t *testing.T) { | ||
t.Run("nominal case", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
api := setupAPI(t) | ||
|
||
|
||
rec, ctx, err := setupRecorder(healthEndpoint, nil) | ||
require.NoError(t, err) | ||
|
||
err = api.Health(ctx) | ||
require.NoError(t, err) | ||
|
||
var res response.Health | ||
require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &res)) | ||
|
||
|
||
require.Equal(t, http.StatusOK, res.Code) | ||
require.Equal(t, http.StatusOK, rec.Result().StatusCode) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters