MCPcopy
hub / github.com/cli/cli / TestCloneRun

Function TestCloneRun

pkg/cmd/label/clone_test.go:81–585  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestCloneRun(t *testing.T) {
82 tests := []struct {
83 name string
84 tty bool
85 opts *cloneOptions
86 httpStubs func(*httpmock.Registry)
87 wantStdout string
88 wantErr bool
89 wantErrMsg string
90 }{
91 {
92 name: "clones all labels",
93 tty: true,
94 opts: &cloneOptions{SourceRepo: ghrepo.New("cli", "cli")},
95 httpStubs: func(reg *httpmock.Registry) {
96 reg.Register(
97 httpmock.GraphQL(`query LabelList\b`),
98 httpmock.GraphQLQuery(`
99 {
100 "data": {
101 "repository": {
102 "labels": {
103 "totalCount": 2,
104 "nodes": [
105 {
106 "name": "bug",
107 "color": "d73a4a",
108 "description": "Something isn't working"
109 },
110 {
111 "name": "docs",
112 "color": "6cafc9"
113 }
114 ],
115 "pageInfo": {
116 "hasNextPage": false,
117 "endCursor": "abcd1234"
118 }
119 }
120 }
121 }
122 }`, func(s string, m map[string]interface{}) {
123 expected := map[string]interface{}{
124 "owner": "cli",
125 "repo": "cli",
126 "orderBy": map[string]interface{}{
127 "direction": "ASC",
128 "field": "CREATED_AT",
129 },
130 "query": "",
131 "limit": float64(100),
132 }
133 assert.Equal(t, expected, m)
134 }),
135 )
136 reg.Register(
137 httpmock.REST("POST", "repos/OWNER/REPO/labels"),
138 httpmock.StatusStringResponse(201, `

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
NewFunction · 0.92
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
StringResponseFunction · 0.92
WithHeaderFunction · 0.92
TestFunction · 0.92
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected