"Fossies" - the Fresh Open Source Software Archive  

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

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

create_test.go  (gh-cli-1.12.0):create_test.go  (gh-cli-1.12.1)
skipping to change at line 625 skipping to change at line 625
if len(reg.Requests) != 3 { if len(reg.Requests) != 3 {
t.Fatalf("expected 3 HTTP request, got %d", len(reg.Requests)) t.Fatalf("expected 3 HTTP request, got %d", len(reg.Requests))
} }
bodyBytes, _ := ioutil.ReadAll(reg.Requests[2].Body) bodyBytes, _ := ioutil.ReadAll(reg.Requests[2].Body)
_ = json.Unmarshal(bodyBytes, &reqBody) _ = json.Unmarshal(bodyBytes, &reqBody)
if repoName := reqBody.Name; repoName != "REPO" { if repoName := reqBody.Name; repoName != "REPO" {
t.Errorf("expected %q, got %q", "REPO", repoName) t.Errorf("expected %q, got %q", "REPO", repoName)
} }
if repoVisibility := reqBody.Visibility; repoVisibility != "PRIVATE" { if repoVisibility := reqBody.Visibility; repoVisibility != "private" {
t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility) t.Errorf("expected %q, got %q", "private", repoVisibility)
} }
if ownerId := reqBody.OwnerId; ownerId != "OWNERID" { if ownerId := reqBody.OwnerId; ownerId != "OWNERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId) t.Errorf("expected %q, got %q", "OWNERID", ownerId)
} }
} }
func TestRepoCreate_WithBothGitIgnoreLicense(t *testing.T) { func TestRepoCreate_WithBothGitIgnoreLicense(t *testing.T) {
cs, cmdTeardown := run.Stub() cs, cmdTeardown := run.Stub()
defer cmdTeardown(t) defer cmdTeardown(t)
skipping to change at line 724 skipping to change at line 724
if len(reg.Requests) != 4 { if len(reg.Requests) != 4 {
t.Fatalf("expected 4 HTTP request, got %d", len(reg.Requests)) t.Fatalf("expected 4 HTTP request, got %d", len(reg.Requests))
} }
bodyBytes, _ := ioutil.ReadAll(reg.Requests[3].Body) bodyBytes, _ := ioutil.ReadAll(reg.Requests[3].Body)
_ = json.Unmarshal(bodyBytes, &reqBody) _ = json.Unmarshal(bodyBytes, &reqBody)
if repoName := reqBody.Name; repoName != "REPO" { if repoName := reqBody.Name; repoName != "REPO" {
t.Errorf("expected %q, got %q", "REPO", repoName) t.Errorf("expected %q, got %q", "REPO", repoName)
} }
if repoVisibility := reqBody.Visibility; repoVisibility != "PRIVATE" { if repoVisibility := reqBody.Visibility; repoVisibility != "private" {
t.Errorf("expected %q, got %q", "PRIVATE", repoVisibility) t.Errorf("expected %q, got %q", "private", repoVisibility)
}
if ownerId := reqBody.OwnerId; ownerId != "OWNERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId)
}
}
func TestRepoCreate_WithGitIgnore_Org(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", "type":"Organiza
tion" }`))
reg.Register(
httpmock.REST("GET", "gitignore/templates"),
httpmock.StringResponse(`["Actionscript","Android","AppceleratorT
itanium","Autotools","Bancha","C","C++","Go"]`))
reg.Register(
httpmock.REST("POST", "orgs/OWNER/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" { if ownerId := reqBody.OwnerId; ownerId != "OWNERID" {
t.Errorf("expected %q, got %q", "OWNERID", ownerId) t.Errorf("expected %q, got %q", "OWNERID", ownerId)
} }
} }
 End of changes. 2 change blocks. 
4 lines changed or deleted 98 lines changed or added

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