mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-09-03 07:24:52 +08:00
29 lines
664 B
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)
|
|
}
|