package common import ( "net/http" "net/http/httptest" "strings" "testing" "github.com/QuantumNous/new-api/constant" "github.com/gin-gonic/gin" "github.com/stretchr/testify/require" ) func TestValidateMultipartDirectNormalizesImageField(t *testing.T) { gin.SetMode(gin.TestMode) body := strings.NewReader(`{"model":"wan2.7-i2v","prompt":"animate","image":" https://example.com/first.png "}`) request := httptest.NewRequest(http.MethodPost, "/v1/video/generations", body) request.Header.Set("Content-Type", "application/json") recorder := httptest.NewRecorder() context, _ := gin.CreateTestContext(recorder) context.Request = request info := &RelayInfo{ TaskRelayInfo: &TaskRelayInfo{}, } taskErr := ValidateMultipartDirect(context, info) require.Nil(t, taskErr) storedReq, err := GetTaskRequest(context) require.NoError(t, err) require.Equal(t, []string{"https://example.com/first.png"}, storedReq.Images) require.Equal(t, constant.TaskActionGenerate, info.Action) }