43 lines
1.7 KiB
Go
43 lines
1.7 KiB
Go
package api
|
|
|
|
import (
|
|
"bytes"
|
|
"droboticflow/internal/domain"
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestContinuousOnlyRemovesManualRunEndpoints(t *testing.T) {
|
|
f := newCombinedDraftFixture(t)
|
|
for _, path := range []string{"/api/workflows/draft-workflow/run", "/api/workflow-releases/old/runs", "/api/runs/old/rerun-subtree", "/api/scan-configs/old/run", "/api/data-collection-tasks/old/start", "/api/acceptance/poc-gpu-workflow", "/api/acceptance/poc-operator-workflows", "/worker-api/runs/old/retry"} {
|
|
r := f.request(http.MethodPost, path, f.admin, map[string]any{"mode": "production", "trigger": "manual"})
|
|
if r.Code != http.StatusNotFound && r.Code != http.StatusMethodNotAllowed {
|
|
t.Fatalf("retired endpoint %s returned %d: %s", path, r.Code, r.Body.String())
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestContinuousOnlyTemplateCreation(t *testing.T) {
|
|
f := newCombinedDraftFixture(t)
|
|
for _, typ := range []string{"batch", "single", "debug"} {
|
|
r := f.request(http.MethodPost, "/api/templates", f.admin, map[string]any{"name": "reject legacy", "type": typ})
|
|
if r.Code != http.StatusBadRequest {
|
|
t.Fatalf("legacy %s accepted: %d %s", typ, r.Code, r.Body.String())
|
|
}
|
|
}
|
|
r := f.request(http.MethodPost, "/api/templates", f.admin, map[string]any{"name": "continuous default"})
|
|
if r.Code != http.StatusCreated || !bytes.Contains(r.Body.Bytes(), []byte(`"type":"streaming"`)) {
|
|
t.Fatalf("continuous default: %d %s", r.Code, r.Body.String())
|
|
}
|
|
}
|
|
|
|
func TestContinuousOnlyRejectsWholeWorkflowTimerAndSandbox(t *testing.T) {
|
|
if validWorkflowExecutionScope(domain.WorkflowExecutionScopeSandbox) {
|
|
t.Fatal("sandbox execution still enabled")
|
|
}
|
|
schedule := &domain.WorkflowSchedule{Interval: 30}
|
|
if len(validateWorkflowSchedule(schedule)) == 0 {
|
|
t.Fatal("whole workflow schedule still accepted")
|
|
}
|
|
}
|