MCPcopy
hub / github.com/cli/cli / TestApiActorsSupported

Function TestApiActorsSupported

pkg/cmd/issue/edit/edit_test.go:1535–1612  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1533}
1534
1535func TestApiActorsSupported(t *testing.T) {
1536 t.Run("when actors are assignable, query includes assignedActors", func(t *testing.T) {
1537 ios, _, _, _ := iostreams.Test()
1538
1539 reg := &httpmock.Registry{}
1540 reg.Register(
1541 httpmock.GraphQL(`assignedActors`),
1542 // Simulate a GraphQL error to early exit the test.
1543 httpmock.StatusStringResponse(500, ""),
1544 )
1545
1546 _, cmdTeardown := run.Stub()
1547 defer cmdTeardown(t)
1548
1549 // Ignore the error because we don't care.
1550 _ = editRun(&EditOptions{
1551 IO: ios,
1552 HttpClient: func() (*http.Client, error) {
1553 return &http.Client{Transport: reg}, nil
1554 },
1555 BaseRepo: func() (ghrepo.Interface, error) {
1556 return ghrepo.New("OWNER", "REPO"), nil
1557 },
1558 Detector: &fd.EnabledDetectorMock{},
1559 IssueNumbers: []int{123},
1560 Editable: prShared.Editable{
1561 Assignees: prShared.EditableAssignees{
1562 EditableSlice: prShared.EditableSlice{
1563 Add: []string{"monalisa", "octocat"},
1564 Edited: true,
1565 },
1566 },
1567 },
1568 })
1569
1570 reg.Verify(t)
1571 })
1572
1573 t.Run("when actors are not assignable, query includes assignees instead", func(t *testing.T) {
1574 ios, _, _, _ := iostreams.Test()
1575
1576 reg := &httpmock.Registry{}
1577 // This test should NOT include assignedActors in the query
1578 reg.Exclude(t, httpmock.GraphQL(`assignedActors`))
1579 // It should include the regular assignees field
1580 reg.Register(
1581 httpmock.GraphQL(`assignees`),
1582 // Simulate a GraphQL error to early exit the test.
1583 httpmock.StatusStringResponse(500, ""),
1584 )
1585
1586 _, cmdTeardown := run.Stub()
1587 defer cmdTeardown(t)
1588
1589 // Ignore the error because we're not really interested in it.
1590 _ = editRun(&EditOptions{
1591 IO: ios,
1592 HttpClient: func() (*http.Client, error) {

Callers

nothing calls this directly

Calls 10

RegisterMethod · 0.95
VerifyMethod · 0.95
ExcludeMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StatusStringResponseFunction · 0.92
StubFunction · 0.92
NewFunction · 0.92
editRunFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected