本文整理匯總了Golang中github.com/github/hub/fixtures.SetupTestRepo函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetupTestRepo函數的具體用法?Golang SetupTestRepo怎麽用?Golang SetupTestRepo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetupTestRepo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkSavedReportCrashOption
func checkSavedReportCrashOption(t *testing.T, always bool, confirm, expected string) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
saveReportConfiguration(confirm, always)
assert.Equal(t, expected, reportCrashConfig())
}
示例2: TestGitDir
func TestGitDir(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
gitDir, _ := Dir()
assert.T(t, strings.Contains(gitDir, ".git"))
}
示例3: TestGitShow
func TestGitShow(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
output, err := Show("9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06")
assert.Equal(t, nil, err)
assert.Equal(t, "First comment\n\nMore comment", output)
}
示例4: TestGitLog
func TestGitLog(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
log, err := Log("08f4b7b6513dffc6245857e497cfd6101dc47818", "9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06")
assert.Equal(t, nil, err)
assert.NotEqual(t, "", log)
}
示例5: TestGitEditor
func TestGitEditor(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
SetGlobalConfig("core.editor", "foo")
gitEditor, err := Editor()
assert.Equal(t, nil, err)
assert.Equal(t, "foo", gitEditor)
}
示例6: TestGitRef
func TestGitRef(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
ref := "08f4b7b6513dffc6245857e497cfd6101dc47818"
gitRef, err := Ref(ref)
assert.Equal(t, nil, err)
assert.Equal(t, ref, gitRef)
}
示例7: checkSavedAutoUpdateOption
func checkSavedAutoUpdateOption(t *testing.T, always bool, confirm, expected string) {
EnableAutoUpdate = true
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
saveAutoUpdateConfiguration(confirm, always)
assert.Equal(t, expected, autoUpdateConfig())
EnableAutoUpdate = false
}
示例8: TestGitRefList
func TestGitRefList(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
refList, err := RefList("08f4b7b6513dffc6245857e497cfd6101dc47818", "9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06")
assert.Equal(t, nil, err)
assert.Equal(t, 1, len(refList))
assert.Equal(t, "9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06", refList[0])
}
示例9: TestRemotes
func TestRemotes(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
type remote struct {
name string
url string
pushUrl string
}
testCases := map[string]remote{
"testremote1": {
"testremote1",
"https://example.com/test1/project1.git",
"no_push",
},
"testremote2": {
"testremote2",
"[email protected]:test2/project2.git",
"http://example.com/project.git",
},
"testremote3": {
"testremote3",
"https://example.com/test1/project2.git",
"",
},
}
for _, tc := range testCases {
repo.AddRemote(tc.name, tc.url, tc.pushUrl)
}
remotes, err := Remotes()
assert.Equal(t, nil, err)
// In addition to the remotes we added to the repo, repo will
// also have an additional remote "origin". So add it to the
// expected cases to test.
wantCases := map[string]struct{}{
fmt.Sprintf("origin %s (fetch)", repo.Remote): {},
fmt.Sprintf("origin %s (push)", repo.Remote): {},
"testremote1 https://example.com/test1/project1.git (fetch)": {},
"testremote1 no_push (push)": {},
"testremote2 [email protected]:test2/project2.git (fetch)": {},
"testremote2 http://example.com/project.git (push)": {},
"testremote3 https://example.com/test1/project2.git (fetch)": {},
"testremote3 https://example.com/test1/project2.git (push)": {},
}
assert.Equal(t, len(remotes), len(wantCases))
for _, got := range remotes {
if _, ok := wantCases[got]; !ok {
t.Errorf("Unexpected remote: %s", got)
}
}
}
示例10: TestGitHubRepo_OriginRemote
func TestGitHubRepo_OriginRemote(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
localRepo, _ := LocalRepo()
gitRemote, _ := localRepo.OriginRemote()
assert.Equal(t, "origin", gitRemote.Name)
u, _ := url.Parse(repo.Remote)
assert.Equal(t, u, gitRemote.URL)
}
示例11: TestGithubTemplate_withoutTemplate
func TestGithubTemplate_withoutTemplate(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
pwd, _ := os.Getwd()
tpl, err := ReadTemplate(PullRequestTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, "", tpl)
tpl, err = ReadTemplate(IssueTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, "", tpl)
}
示例12: TestGithubTemplate_withInvalidTemplate
func TestGithubTemplate_withInvalidTemplate(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
addGithubTemplates(repo, map[string]string{"dir": "invalidPath"})
pwd, _ := os.Getwd()
tpl, err := ReadTemplate(PullRequestTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, "", tpl)
tpl, err = ReadTemplate(IssueTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, "", tpl)
}
示例13: TestGithubTemplate_WithTemplateInGithubDir
func TestGithubTemplate_WithTemplateInGithubDir(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
addGithubTemplates(repo, map[string]string{"dir": githubTemplateDir})
pwd, _ := os.Getwd()
tpl, err := ReadTemplate(PullRequestTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, prContent, tpl)
tpl, err = ReadTemplate(IssueTemplate, pwd)
assert.Equal(t, nil, err)
assert.Equal(t, issueContent, tpl)
}
示例14: TestGithubRemote_ColonSlash
func TestGithubRemote_ColonSlash(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
remoteName := "upstream"
repo.AddRemote(remoteName, "[email protected]:/fatso83/my-project.git", "")
remotes, err := Remotes()
assert.Equal(t, nil, err)
assert.Equal(t, len(remotes), 2)
assert.Equal(t, remotes[0].Name, remoteName)
assert.Equal(t, remotes[0].URL.Scheme, "ssh")
assert.Equal(t, remotes[0].URL.Host, "github.com")
assert.Equal(t, remotes[0].URL.Path, "/fatso83/my-project.git")
assert.Equal(t, remotes[1].Name, "origin")
assert.Equal(t, remotes[1].URL.Path, repo.Remote)
}
示例15: TestGithubRemote_SshPort
func TestGithubRemote_SshPort(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
remoteName := "upstream"
repo.AddRemote(remoteName, "ssh://[email protected]:22/hakatashi/dotfiles.git", "")
remotes, err := Remotes()
assert.Equal(t, nil, err)
assert.Equal(t, len(remotes), 2)
assert.Equal(t, remotes[0].Name, remoteName)
assert.Equal(t, remotes[0].URL.Scheme, "ssh")
assert.Equal(t, remotes[0].URL.Host, "github.com")
assert.Equal(t, remotes[0].URL.Path, "/hakatashi/dotfiles.git")
assert.Equal(t, remotes[1].Name, "origin")
assert.Equal(t, remotes[1].URL.Path, repo.Remote)
}