MCPcopy Create free account
hub / github.com/cli/cli / TestRunCreate_Org

Function TestRunCreate_Org

pkg/cmd/project/create/create_test.go:152–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestRunCreate_Org(t *testing.T) {
153 defer gock.Off()
154 gock.Observe(gock.DumpRequest)
155 // get org ID
156 gock.New("https://api.github.com").
157 Post("/graphql").
158 MatchType("json").
159 JSON(map[string]interface{}{
160 "query": "query UserOrgOwner.*",
161 "variables": map[string]string{
162 "login": "github",
163 },
164 }).
165 Reply(200).
166 JSON(map[string]interface{}{
167 "data": map[string]interface{}{
168 "organization": map[string]interface{}{
169 "id": "an ID",
170 "login": "github",
171 },
172 },
173 "errors": []interface{}{
174 map[string]interface{}{
175 "type": "NOT_FOUND",
176 "path": []string{"user"},
177 },
178 },
179 })
180
181 // create project
182 gock.New("https://api.github.com").
183 Post("/graphql").
184 BodyString(`{"query":"mutation CreateProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"ownerId":"an ID","title":"a title"}}}`).Reply(200).
185 JSON(map[string]interface{}{
186 "data": map[string]interface{}{
187 "createProjectV2": map[string]interface{}{
188 "projectV2": map[string]interface{}{
189 "title": "a title",
190 "url": "http://a-url.com",
191 "owner": map[string]string{
192 "login": "monalisa",
193 },
194 },
195 },
196 },
197 })
198
199 client := queries.NewTestClient()
200
201 ios, _, stdout, _ := iostreams.Test()
202 ios.SetStdoutTTY(true)
203 config := createConfig{
204 opts: createOpts{
205 title: "a title",
206 owner: "github",
207 },
208 client: client,
209 io: ios,

Callers

nothing calls this directly

Calls 7

NewTestClientFunction · 0.92
TestFunction · 0.92
runCreateFunction · 0.85
ReplyMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected