You've already forked reloading-manager
No changes made
This commit is contained in:
38
backend/handlers/responses_test.go
Normal file
38
backend/handlers/responses_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type TestContext struct {
|
||||
echo.Context
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
func (t TestContext) JSON(code int, i interface{}) error {
|
||||
|
||||
if code != 400 {
|
||||
t.t.Fatal("expected 400")
|
||||
}
|
||||
|
||||
switch i.(type) {
|
||||
case Response[string]:
|
||||
break
|
||||
default:
|
||||
t.t.Fatal("expected response")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestBadRequest(t *testing.T) {
|
||||
context := TestContext{
|
||||
t: t,
|
||||
}
|
||||
|
||||
err := BadRequest(context, "Something is wrong")
|
||||
if err != nil {
|
||||
t.Errorf("Should not have returned an error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user