mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-22 07:04:56 +01:00
Feature: integration testing
Add integration tests with testify/suite. Moved some structs outside of controller funcs so we can re-use them in the testing package. Add CI workflow for running tests on every push.
This commit is contained in:
@@ -19,20 +19,24 @@ func NewAuthController(svc *service.LndhubService) *AuthController {
|
||||
}
|
||||
}
|
||||
|
||||
type AuthRequestBody struct {
|
||||
Login string `json:"login"`
|
||||
Password string `json:"password"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
type AuthResponseBody struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
AccessToken string `json:"access_token"`
|
||||
}
|
||||
|
||||
// Auth : Auth Controller
|
||||
func (controller *AuthController) Auth(c echo.Context) error {
|
||||
type RequestBody struct {
|
||||
Login string `json:"login"`
|
||||
Password string `json:"password"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
var body RequestBody
|
||||
var body AuthRequestBody
|
||||
|
||||
if err := c.Bind(&body); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.Validate(&body); err != nil {
|
||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||
}
|
||||
@@ -42,8 +46,8 @@ func (controller *AuthController) Auth(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, echo.Map{
|
||||
"refresh_token": refreshToken,
|
||||
"access_token": accessToken,
|
||||
return c.JSON(http.StatusOK, &AuthResponseBody{
|
||||
RefreshToken: refreshToken,
|
||||
AccessToken: accessToken,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user