(t *testing.T, r *http.Request, distDir string)
| 478 | } |
| 479 | |
| 480 | func checkCreateDocsRequest(t *testing.T, r *http.Request, distDir string) { |
| 481 | t.Helper() |
| 482 | |
| 483 | body, err := io.ReadAll(r.Body) |
| 484 | if err != nil { |
| 485 | t.Fatal(err) |
| 486 | } |
| 487 | got := map[string]any{} |
| 488 | err = json.Unmarshal(body, &got) |
| 489 | if err != nil { |
| 490 | t.Fatal(err) |
| 491 | } |
| 492 | |
| 493 | customDocContent := readFile(distDir + "/docs/Custom-Doc.md") |
| 494 | overviewContent := readFile(distDir + "/docs/overview.md") |
| 495 | configurationContent := readFile(distDir + "/docs/configuration.md") |
| 496 | |
| 497 | want := map[string]any{ |
| 498 | "pages": []any{ |
| 499 | map[string]any{ |
| 500 | "content": customDocContent, |
| 501 | "name": "Custom-Doc", |
| 502 | }, |
| 503 | map[string]any{ |
| 504 | "content": configurationContent, |
| 505 | "name": "configuration", |
| 506 | }, |
| 507 | map[string]any{ |
| 508 | "content": overviewContent, |
| 509 | "name": "overview", |
| 510 | }, |
| 511 | }, |
| 512 | } |
| 513 | if diff := cmp.Diff(want, got); diff != "" { |
| 514 | t.Fatalf("mismatch (-want +got):\n%s", diff) |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | func readFile(name string) string { |
| 519 | b, err := os.ReadFile(name) |
no test coverage detected