Files
descrybe/apps/api/internal/httpapi/v1_feeds_test.go
T
2026-08-17 21:20:45 +02:00

43 lines
963 B
Go

package httpapi
import (
"strings"
"testing"
)
func TestV1OpenAPIFeedsLegacyContract(t *testing.T) {
t.Parallel()
body := string(v1OpenAPIYAML)
for _, needle := range []string{
"Paged list — { data: Feed[], meta: { page, limit, total } }",
"required: [name, item_path]",
"jobId:",
"FeedSyncResponse",
"PresentFeed",
"item_path:",
"is_active:",
"product_count:",
"last_synced:",
"HTTP 200 { data: { jobId } }",
} {
if !strings.Contains(body, needle) {
t.Fatalf("openapi feeds section missing %q", needle)
}
}
syncIdx := strings.Index(body, "/feeds/{id}/sync:")
if syncIdx < 0 {
t.Fatal("missing sync path")
}
chunk := body[syncIdx:]
end := strings.Index(chunk, "\n /feeds/{id}/mappings:")
if end > 0 {
chunk = chunk[:end]
}
if !strings.Contains(chunk, `"200":`) {
t.Fatalf("sync path missing 200 response")
}
if strings.Contains(chunk, `"202":`) {
t.Fatalf("public sync path should not advertise 202")
}
}