diff --git a/internal/handler/application.go b/internal/handler/application.go index ae8534f..2b76332 100644 --- a/internal/handler/application.go +++ b/internal/handler/application.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "strconv" - "strings" "gcy_hpc_server/internal/model" "gcy_hpc_server/internal/server" @@ -139,7 +138,8 @@ func (h *ApplicationHandler) DeleteApplication(c *gin.Context) { server.OK(c, gin.H{"message": "application deleted"}) } -func (h *ApplicationHandler) SubmitApplication(c *gin.Context) { +// [已禁用] 前端已全部迁移到 POST /tasks 接口,此端点不再使用。 +/* func (h *ApplicationHandler) SubmitApplication(c *gin.Context) { id, err := strconv.ParseInt(c.Param("id"), 10, 64) if err != nil { h.logger.Warn("invalid application id for submit", zap.String("id", c.Param("id"))) @@ -171,4 +171,4 @@ func (h *ApplicationHandler) SubmitApplication(c *gin.Context) { } h.logger.Info("application submitted", zap.Int64("id", id), zap.Int32("job_id", resp.JobID)) server.Created(c, resp) -} +} */ diff --git a/internal/handler/application_test.go b/internal/handler/application_test.go index dbc7fa1..ea52a0c 100644 --- a/internal/handler/application_test.go +++ b/internal/handler/application_test.go @@ -46,7 +46,7 @@ func setupApplicationRouter(h *ApplicationHandler) *gin.Engine { apps.GET("/:id", h.GetApplication) apps.PUT("/:id", h.UpdateApplication) apps.DELETE("/:id", h.DeleteApplication) - apps.POST("/:id/submit", h.SubmitApplication) + // apps.POST("/:id/submit", h.SubmitApplication) // [已禁用] 已被 POST /tasks 取代 return r } @@ -344,6 +344,8 @@ func TestDeleteApplication_Success(t *testing.T) { // ---- Submit Tests ---- +// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉 +/* func TestSubmitApplication_Success(t *testing.T) { slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -378,7 +380,10 @@ func TestSubmitApplication_Success(t *testing.T) { t.Fatalf("expected 201, got %d: %s", w2.Code, w2.Body.String()) } } +*/ +// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉 +/* func TestSubmitApplication_AppNotFound(t *testing.T) { slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -398,7 +403,10 @@ func TestSubmitApplication_AppNotFound(t *testing.T) { t.Fatalf("expected 404, got %d: %s", w.Code, w.Body.String()) } } +*/ +// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉 +/* func TestSubmitApplication_ValidationFail(t *testing.T) { slurmHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -430,6 +438,7 @@ func TestSubmitApplication_ValidationFail(t *testing.T) { t.Fatalf("expected 400, got %d: %s", w2.Code, w2.Body.String()) } } +*/ // ---- Logging Tests ---- @@ -529,6 +538,8 @@ func TestApplicationLogging_DeleteSuccess_LogsInfoWithID(t *testing.T) { } } +// [已禁用] 测试的是旧的直接提交路径,该路径已被注释掉 +/* func TestApplicationLogging_SubmitSuccess_LogsInfoWithID(t *testing.T) { core, recorded := observer.New(zapcore.DebugLevel) l := zap.New(core) @@ -581,6 +592,7 @@ func TestApplicationLogging_SubmitSuccess_LogsInfoWithID(t *testing.T) { t.Fatal("expected 'application submitted' log message") } } +*/ func TestApplicationLogging_CreateBadRequest_LogsWarn(t *testing.T) { h, _, recorded := setupApplicationHandlerWithObserver() diff --git a/internal/server/server.go b/internal/server/server.go index e74c119..86141ac 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -31,7 +31,7 @@ type ApplicationHandler interface { GetApplication(c *gin.Context) UpdateApplication(c *gin.Context) DeleteApplication(c *gin.Context) - SubmitApplication(c *gin.Context) + // SubmitApplication(c *gin.Context) // [已禁用] 已被 POST /tasks 取代 } type UploadHandler interface { @@ -93,7 +93,7 @@ func NewRouter(jobH JobHandler, clusterH ClusterHandler, appH ApplicationHandler apps.GET("/:id", appH.GetApplication) apps.PUT("/:id", appH.UpdateApplication) apps.DELETE("/:id", appH.DeleteApplication) - apps.POST("/:id/submit", appH.SubmitApplication) + // apps.POST("/:id/submit", appH.SubmitApplication) // [已禁用] 已被 POST /tasks 取代 files := v1.Group("/files") @@ -164,7 +164,7 @@ func registerPlaceholderRoutes(v1 *gin.RouterGroup) { apps.GET("/:id", notImplemented) apps.PUT("/:id", notImplemented) apps.DELETE("/:id", notImplemented) - apps.POST("/:id/submit", notImplemented) + // apps.POST("/:id/submit", notImplemented) // [已禁用] 已被 POST /tasks 取代 files := v1.Group("/files") diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 4cc5787..9aa51ec 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -32,7 +32,7 @@ func TestAllRoutesRegistered(t *testing.T) { {"GET", "/api/v1/applications/:id"}, {"PUT", "/api/v1/applications/:id"}, {"DELETE", "/api/v1/applications/:id"}, - {"POST", "/api/v1/applications/:id/submit"}, + // {"POST", "/api/v1/applications/:id/submit"}, // [已禁用] 已被 POST /tasks 取代 } routeMap := map[string]bool{}