"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/repo/create/create_test.go" between
gh-cli-1.11.0.tar.gz and gh-cli-1.12.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

create_test.go  (gh-cli-1.11.0):create_test.go  (gh-cli-1.12.0)
skipping to change at line 100 skipping to change at line 100
as, surveyTearDown := prompt.InitAskStubber() as, surveyTearDown := prompt.InitAskStubber()
defer surveyTearDown() defer surveyTearDown()
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "repoVisibility", Name: "repoVisibility",
Value: "PRIVATE", Value: "PRIVATE",
}, },
}) })
as.Stub([]*prompt.QuestionStub{
{
Name: "addGitIgnore",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addLicense",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "confirmSubmit", Name: "confirmSubmit",
Value: true, Value: true,
}, },
}) })
output, err := runCommand(httpClient, "REPO", true) output, err := runCommand(httpClient, "REPO", true)
if err != nil { if err != nil {
t.Errorf("error running command `repo create`: %v", err) t.Errorf("error running command `repo create`: %v", err)
skipping to change at line 233 skipping to change at line 248
as, surveyTearDown := prompt.InitAskStubber() as, surveyTearDown := prompt.InitAskStubber()
defer surveyTearDown() defer surveyTearDown()
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "repoVisibility", Name: "repoVisibility",
Value: "PRIVATE", Value: "PRIVATE",
}, },
}) })
as.Stub([]*prompt.QuestionStub{
{
Name: "addGitIgnore",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addLicense",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "confirmSubmit", Name: "confirmSubmit",
Value: true, Value: true,
}, },
}) })
output, err := runCommand(httpClient, "ORG/REPO", true) output, err := runCommand(httpClient, "ORG/REPO", true)
if err != nil { if err != nil {
t.Errorf("error running command `repo create`: %v", err) t.Errorf("error running command `repo create`: %v", err)
skipping to change at line 309 skipping to change at line 339
as, surveyTearDown := prompt.InitAskStubber() as, surveyTearDown := prompt.InitAskStubber()
defer surveyTearDown() defer surveyTearDown()
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "repoVisibility", Name: "repoVisibility",
Value: "PRIVATE", Value: "PRIVATE",
}, },
}) })
as.Stub([]*prompt.QuestionStub{
{
Name: "addGitIgnore",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addLicense",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "confirmSubmit", Name: "confirmSubmit",
Value: true, Value: true,
}, },
}) })
output, err := runCommand(httpClient, "ORG/REPO --team monkeys", true) output, err := runCommand(httpClient, "ORG/REPO --team monkeys", true)
if err != nil { if err != nil {
t.Errorf("error running command `repo create`: %v", err) t.Errorf("error running command `repo create`: %v", err)
skipping to change at line 459 skipping to change at line 504
}, },
{ {
Name: "repoDescription", Name: "repoDescription",
Value: "DESCRIPTION", Value: "DESCRIPTION",
}, },
{ {
Name: "repoVisibility", Name: "repoVisibility",
Value: "PRIVATE", Value: "PRIVATE",
}, },
}) })
as.Stub([]*prompt.QuestionStub{ as.Stub([]*prompt.QuestionStub{
{ {
Name: "confirmSubmit", Name: "confirmSubmit",
Value: true, Value: true,
}, },
}) })
output, err := runCommand(httpClient, "", true) output, err := runCommand(httpClient, "", true)
if err != nil { if err != nil {
t.Errorf("error running command `repo create`: %v", err) t.Errorf("error running command `repo create`: %v", err)
skipping to change at line 497 skipping to change at line 543
if repoName := reqBody.Variables.Input["name"].(string); repoName != "REP O" { if repoName := reqBody.Variables.Input["name"].(string); repoName != "REP O" {
t.Errorf("expected %q, got %q", "REPO", repoName) t.Errorf("expected %q, got %q", "REPO", repoName)
} }
if repoVisibility := reqBody.Variables.Input["visibility"].(string); repo Visibility != "PRIVATE" { if repoVisibility := reqBody.Variables.Input["visibility"].(string); repo Visibility != "PRIVATE" {
t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility) t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility)
} }
if ownerId := reqBody.Variables.Input["ownerId"].(string); ownerId != "OW NERID" { if ownerId := reqBody.Variables.Input["ownerId"].(string); ownerId != "OW NERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId) t.Errorf("expected %q, got %q", "OWNERID", ownerId)
} }
} }
func TestRepoCreate_WithGitIgnore(t *testing.T) {
cs, cmdTeardown := run.Stub()
defer cmdTeardown(t)
cs.Register(`git remote add -f origin https://github\.com/OWNER/REPO\.git
`, 0, "")
cs.Register(`git rev-parse --show-toplevel`, 0, "")
as, surveyTearDown := prompt.InitAskStubber()
defer surveyTearDown()
as.Stub([]*prompt.QuestionStub{
{
Name: "repoVisibility",
Value: "PRIVATE",
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addGitIgnore",
Value: true,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "chooseGitIgnore",
Value: "Go",
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addLicense",
Value: false,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "confirmSubmit",
Value: true,
},
})
reg := &httpmock.Registry{}
reg.Register(
httpmock.REST("GET", "users/OWNER"),
httpmock.StringResponse(`{ "node_id": "OWNERID" }`))
reg.Register(
httpmock.REST("GET", "gitignore/templates"),
httpmock.StringResponse(`["Actionscript","Android","AppceleratorT
itanium","Autotools","Bancha","C","C++","Go"]`))
reg.Register(
httpmock.REST("POST", "user/repos"),
httpmock.StringResponse(`{"name":"REPO", "owner":{"login": "OWNER
"}, "html_url":"https://github.com/OWNER/REPO"}`))
httpClient := &http.Client{Transport: reg}
output, err := runCommand(httpClient, "OWNER/REPO", true)
if err != nil {
t.Errorf("error running command `repo create`: %v", err)
}
assert.Equal(t, "", output.String())
assert.Equal(t, "✓ Created repository OWNER/REPO on GitHub\n✓ Added remot
e https://github.com/OWNER/REPO.git\n", output.Stderr())
var reqBody struct {
Name string
Visibility string
OwnerId string
LicenseTemplate string
}
if len(reg.Requests) != 3 {
t.Fatalf("expected 3 HTTP request, got %d", len(reg.Requests))
}
bodyBytes, _ := ioutil.ReadAll(reg.Requests[2].Body)
_ = json.Unmarshal(bodyBytes, &reqBody)
if repoName := reqBody.Name; repoName != "REPO" {
t.Errorf("expected %q, got %q", "REPO", repoName)
}
if repoVisibility := reqBody.Visibility; repoVisibility != "PRIVATE" {
t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility)
}
if ownerId := reqBody.OwnerId; ownerId != "OWNERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId)
}
}
func TestRepoCreate_WithBothGitIgnoreLicense(t *testing.T) {
cs, cmdTeardown := run.Stub()
defer cmdTeardown(t)
cs.Register(`git remote add -f origin https://github\.com/OWNER/REPO\.git
`, 0, "")
cs.Register(`git rev-parse --show-toplevel`, 0, "")
as, surveyTearDown := prompt.InitAskStubber()
defer surveyTearDown()
as.Stub([]*prompt.QuestionStub{
{
Name: "repoVisibility",
Value: "PRIVATE",
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addGitIgnore",
Value: true,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "chooseGitIgnore",
Value: "Go",
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "addLicense",
Value: true,
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "chooseLicense",
Value: "GNU Affero General Public License v3.0",
},
})
as.Stub([]*prompt.QuestionStub{
{
Name: "confirmSubmit",
Value: true,
},
})
reg := &httpmock.Registry{}
reg.Register(
httpmock.REST("GET", "users/OWNER"),
httpmock.StringResponse(`{ "node_id": "OWNERID" }`))
reg.Register(
httpmock.REST("GET", "gitignore/templates"),
httpmock.StringResponse(`["Actionscript","Android","AppceleratorT
itanium","Autotools","Bancha","C","C++","Go"]`))
reg.Register(
httpmock.REST("GET", "licenses"),
httpmock.StringResponse(`[{"key": "mit","name": "MIT License"},{"
key": "lgpl-3.0","name": "GNU Lesser General Public License v3.0"}]`))
reg.Register(
httpmock.REST("POST", "user/repos"),
httpmock.StringResponse(`{"name":"REPO", "owner":{"login": "OWNER
"}, "html_url":"https://github.com/OWNER/REPO"}`))
httpClient := &http.Client{Transport: reg}
output, err := runCommand(httpClient, "OWNER/REPO", true)
if err != nil {
t.Errorf("error running command `repo create`: %v", err)
}
assert.Equal(t, "", output.String())
assert.Equal(t, "✓ Created repository OWNER/REPO on GitHub\n✓ Added remot
e https://github.com/OWNER/REPO.git\n", output.Stderr())
var reqBody struct {
Name string
Visibility string
OwnerId string
LicenseTemplate string
}
if len(reg.Requests) != 4 {
t.Fatalf("expected 4 HTTP request, got %d", len(reg.Requests))
}
bodyBytes, _ := ioutil.ReadAll(reg.Requests[3].Body)
_ = json.Unmarshal(bodyBytes, &reqBody)
if repoName := reqBody.Name; repoName != "REPO" {
t.Errorf("expected %q, got %q", "REPO", repoName)
}
if repoVisibility := reqBody.Visibility; repoVisibility != "PRIVATE" {
t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility)
}
if ownerId := reqBody.OwnerId; ownerId != "OWNERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId)
}
}
 End of changes. 5 change blocks. 
0 lines changed or deleted 46 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)