fixing test

This commit is contained in:
zach rice committed 2019-06-02 20:55:24 -05:00
1 parent 57bfa41b33
commit 3b6c198715
2 files changed
+13 -6

No files matched your search

+4 -4
View File
@@ -64,22 +64,22 @@ func TestGetRepo(t *testing.T) {
Repo: "https://github.com/gitleakstest/nope", Repo: "https://github.com/gitleakstest/nope",
}, },
description: "test no repo", description: "test no repo",
expectedErrMsg: "authentication required", expectedErrMsg: "repository not found",
}, },
{ {
testOpts: &Options{ testOpts: &Options{
Repo: "https://github.com/gitleakstest/private", Repo: "https://github.com/gitleakstest/private",
}, },
description: "test private repo", description: "test private repo",
expectedErrMsg: "authentication required", expectedErrMsg: "repository not found",
}, },
{ {
testOpts: &Options{ testOpts: &Options{
Repo: "https://github.com/gitleakstest/private", Repo: "https://github.com/gitleakstest/private",
Disk: true, Disk: true,
}, },
description: "test private repo", description: "test private repo disk",
expectedErrMsg: "authentication required", expectedErrMsg: "repository not found",
}, },
} }
g := goblin.Goblin(t) g := goblin.Goblin(t)
+9 -2
View File
@@ -78,10 +78,17 @@ func (repoInfo *RepoInfo) clone() error {
}) })
} else { } else {
// public // public
repo, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{ options := &git.CloneOptions{
URL: opts.Repo, URL: opts.Repo,
Progress: os.Stdout, Progress: os.Stdout,
}) }
if os.Getenv("GITHUB_TOKEN") != "" {
options.Auth = &gitHttp.BasicAuth{
Username: "fakeUsername", // yes, this can be anything except an empty string
Password: os.Getenv("GITHUB_TOKEN"),
}
}
repo, err = git.PlainClone(cloneTarget, false, options)
} }
} else if repoInfo.path != "" { } else if repoInfo.path != "" {
log.Infof("opening %s", repoInfo.path) log.Infof("opening %s", repoInfo.path)