feat(handler): add Application handler, routes, and wiring

Add ApplicationHandler with CRUD + Submit endpoints. Register 6 routes, wire in app.go, update main_test.go references. 22 handler tests.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-13 17:10:54 +08:00
parent d3eb728c2f
commit 10bb15e5b2
3 changed files with 823 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ import (
func newTestDB() *gorm.DB {
db, _ := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)})
db.AutoMigrate(&model.JobTemplate{})
db.AutoMigrate(&model.Application{})
return db
}
@@ -34,12 +34,15 @@ func TestRouterRegistration(t *testing.T) {
defer slurmSrv.Close()
client, _ := slurm.NewClientWithOpts(slurmSrv.URL, slurm.WithHTTPClient(slurmSrv.Client()))
templateStore := store.NewTemplateStore(newTestDB())
jobSvc := service.NewJobService(client, zap.NewNop())
appStore := store.NewApplicationStore(newTestDB())
appSvc := service.NewApplicationService(appStore, jobSvc, "", zap.NewNop())
appH := handler.NewApplicationHandler(appSvc, zap.NewNop())
router := server.NewRouter(
handler.NewJobHandler(service.NewJobService(client, zap.NewNop()), zap.NewNop()),
handler.NewJobHandler(jobSvc, zap.NewNop()),
handler.NewClusterHandler(service.NewClusterService(client, zap.NewNop()), zap.NewNop()),
handler.NewTemplateHandler(templateStore, zap.NewNop()),
appH,
nil,
)
@@ -58,11 +61,12 @@ func TestRouterRegistration(t *testing.T) {
{"GET", "/api/v1/partitions"},
{"GET", "/api/v1/partitions/:name"},
{"GET", "/api/v1/diag"},
{"GET", "/api/v1/templates"},
{"POST", "/api/v1/templates"},
{"GET", "/api/v1/templates/:id"},
{"PUT", "/api/v1/templates/:id"},
{"DELETE", "/api/v1/templates/:id"},
{"GET", "/api/v1/applications"},
{"POST", "/api/v1/applications"},
{"GET", "/api/v1/applications/:id"},
{"PUT", "/api/v1/applications/:id"},
{"DELETE", "/api/v1/applications/:id"},
{"POST", "/api/v1/applications/:id/submit"},
}
routeMap := map[string]bool{}
@@ -90,12 +94,15 @@ func TestSmokeGetJobsEndpoint(t *testing.T) {
defer slurmSrv.Close()
client, _ := slurm.NewClientWithOpts(slurmSrv.URL, slurm.WithHTTPClient(slurmSrv.Client()))
templateStore := store.NewTemplateStore(newTestDB())
jobSvc := service.NewJobService(client, zap.NewNop())
appStore := store.NewApplicationStore(newTestDB())
appSvc := service.NewApplicationService(appStore, jobSvc, "", zap.NewNop())
appH := handler.NewApplicationHandler(appSvc, zap.NewNop())
router := server.NewRouter(
handler.NewJobHandler(service.NewJobService(client, zap.NewNop()), zap.NewNop()),
handler.NewJobHandler(jobSvc, zap.NewNop()),
handler.NewClusterHandler(service.NewClusterService(client, zap.NewNop()), zap.NewNop()),
handler.NewTemplateHandler(templateStore, zap.NewNop()),
appH,
nil,
)