43 lines
975 B
Go
43 lines
975 B
Go
package httpapi
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestV1OpenAPIFeedsLegacyContract(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
body := string(v1OpenAPIYAML)
|
||
|
|
for _, needle := range []string{
|
||
|
|
"Legacy public contract — { 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")
|
||
|
|
}
|
||
|
|
}
|