(t *testing.T)
| 338 | } |
| 339 | |
| 340 | func Test_editRun_interactive(t *testing.T) { |
| 341 | editList := []string{ |
| 342 | "Default Branch Name", |
| 343 | "Description", |
| 344 | "Home Page URL", |
| 345 | "Issues", |
| 346 | "Merge Options", |
| 347 | "Projects", |
| 348 | "Template Repository", |
| 349 | "Topics", |
| 350 | "Visibility", |
| 351 | "Wikis"} |
| 352 | |
| 353 | tests := []struct { |
| 354 | name string |
| 355 | opts EditOptions |
| 356 | promptStubs func(*prompter.MockPrompter) |
| 357 | httpStubs func(*testing.T, *httpmock.Registry) |
| 358 | wantsStderr string |
| 359 | wantsErr string |
| 360 | }{ |
| 361 | { |
| 362 | name: "forking of org repo", |
| 363 | opts: EditOptions{ |
| 364 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 365 | InteractiveMode: true, |
| 366 | }, |
| 367 | promptStubs: func(pm *prompter.MockPrompter) { |
| 368 | el := append(editList, optionAllowForking) |
| 369 | pm.RegisterMultiSelect("What do you want to edit?", nil, el, |
| 370 | func(_ string, _, opts []string) ([]int, error) { |
| 371 | return []int{10}, nil |
| 372 | }) |
| 373 | pm.RegisterConfirm("Allow forking (of an organization repository)?", func(_ string, _ bool) (bool, error) { |
| 374 | return true, nil |
| 375 | }) |
| 376 | }, |
| 377 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 378 | reg.Register( |
| 379 | httpmock.GraphQL(`query RepositoryInfo\b`), |
| 380 | httpmock.StringResponse(` |
| 381 | { |
| 382 | "data": { |
| 383 | "repository": { |
| 384 | "visibility": "public", |
| 385 | "description": "description", |
| 386 | "homePageUrl": "https://url.com", |
| 387 | "defaultBranchRef": { |
| 388 | "name": "main" |
| 389 | }, |
| 390 | "isInOrganization": true, |
| 391 | "repositoryTopics": { |
| 392 | "nodes": [{ |
| 393 | "topic": { |
| 394 | "name": "x" |
| 395 | } |
| 396 | }] |
| 397 | } |
nothing calls this directly
no test coverage detected