Files
nginx-ui/api/system/self_check_test.go

29 lines
664 B
Go

package system
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSelfCheckFixReturnsErrorStatus(t *testing.T) {
gin.SetMode(gin.TestMode)
recorder := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(recorder)
ctx.Params = gin.Params{{Key: "name", Value: "missing-task"}}
SelfCheckFix(ctx)
assert.Equal(t, http.StatusInternalServerError, recorder.Code)
var body struct {
Code int32 `json:"code"`
}
require.NoError(t, json.Unmarshal(recorder.Body.Bytes(), &body))
assert.Equal(t, int32(40400), body.Code)
}