(t *testing.T)
| 452 | } |
| 453 | |
| 454 | func TestEditRun(t *testing.T) { |
| 455 | apiError := func(status int, message string) error { |
| 456 | u, err := url.Parse("https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts/2") |
| 457 | require.NoError(t, err) |
| 458 | return api.HTTPError{HTTPError: &ghAPI.HTTPError{StatusCode: status, Message: message, RequestURL: u}} |
| 459 | } |
| 460 | uploaded := func(name, asset string) attachments.UploadStub { |
| 461 | return attachments.UploadStub{Name: name, Status: 200, Body: fmt.Sprintf(`{"url": "https://github.com/user-attachments/assets/%s"}`, asset)} |
| 462 | } |
| 463 | const ( |
| 464 | planBody = "# OAuth callback plan\n\n1. Register the callback URL.\n2. Wire up `order-history` sync." |
| 465 | newPlan = "# OAuth callback plan\n\n1. Register the callback URL.\n2. Test the callback on staging.\n" |
| 466 | newPlanFlow = "# OAuth callback plan\n\n\n" |
| 467 | shortcut = "[InternetShortcut]\r\nURL=" + runbookURLv2 + "\r\n" |
| 468 | oldPlanBody = "# OAuth plan\n\n1. Register the callback URL." |
| 469 | menuHTML = "<!doctype html>\n<html>\n<body><h1>Seasonal menu</h1><p>Maple oat latte</p></body>\n</html>\n" |
| 470 | newMenuHTML = "<!doctype html>\n<html>\n<body><h1>Winter menu</h1><p>Chestnut latte</p></body>\n</html>\n" |
| 471 | ) |
| 472 | plan := client.Artifact{Number: 2, Type: "generic", Name: "OAuth callback plan", Body: planBody} |
| 473 | approvedPlan := client.Artifact{Number: 1, Type: "plan", Name: "Approved plan", Body: "# Approved plan"} |
| 474 | runbook := client.Artifact{Number: 3, Type: "link", Name: "Staging OAuth runbook", Body: runbookURL} |
| 475 | badType := client.Artifact{Number: 2, Type: "bad-type", Name: "OAuth callback plan", Body: planBody} |
| 476 | // The HTML document on the spec's issue 166. |
| 477 | menuPrototype := client.Artifact{Number: 1, Type: "embedded_html", Name: "Menu prototype", Body: menuHTML} |
| 478 | // Part of plan's edit history, newest first. Version 9 renamed it, as in |
| 479 | // the spec, and here the current version, 12, has version 9's name and |
| 480 | // body. |
| 481 | planVersions := []client.Version{ |
| 482 | {Version: 12, Name: "OAuth callback plan", Body: planBody}, |
| 483 | {Version: 11, Name: "OAuth callback plan", Body: planBody + "\n3. Test the callback on staging."}, |
| 484 | {Version: 9, Name: "OAuth callback plan", Body: planBody}, |
| 485 | {Version: 5, Name: "OAuth plan", Body: oldPlanBody}, |
| 486 | } |
| 487 | // The runbook after its URL changed, with its first URL as version 1. |
| 488 | movedRunbook := client.Artifact{Number: 3, Type: "link", Name: "Staging OAuth runbook", Body: runbookURLv2} |
| 489 | movedRunbookVersions := []client.Version{ |
| 490 | {Version: 2, Name: "Staging OAuth runbook", Body: runbookURLv2}, |
| 491 | {Version: 1, Name: "Staging OAuth runbook", Body: runbookURL}, |
| 492 | } |
| 493 | |
| 494 | tests := []struct { |
| 495 | name string |
| 496 | repo ghrepo.Interface |
| 497 | files map[string]string |
| 498 | symlinks map[string]string |
| 499 | attach []string |
| 500 | uploads []attachments.UploadStub |
| 501 | stdin string |
| 502 | opts EditOptions |
| 503 | // artifact is what the artifact's lookup returns, with versions as its |
| 504 | // edit history. |
| 505 | artifact client.Artifact |
| 506 | versions []client.Version |
| 507 | tty bool |
| 508 | color bool |
| 509 | isPullRequest bool |
| 510 | lookupErr error |
| 511 | getErr error |
nothing calls this directly
no test coverage detected