Skip to content

Commit

Permalink
cogito: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aliculPix4D committed Oct 30, 2023
1 parent 362de67 commit 66f1cf5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 1 addition & 3 deletions cmd/cogito/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ func TestRunPutSuccess(t *testing.T) {
var ghUrl *url.URL
gitHubSpy := testhelp.SpyHttpServer(&ghReq, nil, &ghUrl, http.StatusCreated)
gitHubSpyURL, err := url.Parse(gitHubSpy.URL)
if err != nil {
t.Fatalf("error parsing SpyHttpServer URL: %s", err)
}
assert.NilError(t, err, "error parsing SpyHttpServer URL: %s", err)
var chatMsg googlechat.BasicMessage
chatReply := googlechat.MessageReply{}
var gchatUrl *url.URL
Expand Down
8 changes: 2 additions & 6 deletions cogito/ghcommitsink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ func TestSinkGitHubCommitStatusSendSuccess(t *testing.T) {
var URL *url.URL
ts := testhelp.SpyHttpServer(&ghReq, nil, &URL, http.StatusCreated)
gitHubSpyURL, err := url.Parse(ts.URL)
if err != nil {
t.Fatalf("error parsing SpyHttpServer URL: %s", err)
}
assert.NilError(t, err, "error parsing SpyHttpServer URL: %s", err)
sink := cogito.GitHubCommitStatusSink{
Log: hclog.NewNullLogger(),
GitRef: wantGitRef,
Expand All @@ -52,9 +50,7 @@ func TestSinkGitHubCommitStatusSendFailure(t *testing.T) {
w.WriteHeader(http.StatusTeapot)
}))
gitHubSpyURL, err := url.Parse(ts.URL)
if err != nil {
t.Fatalf("error parsing SpyHttpServer URL: %s", err)
}
assert.NilError(t, err, "error parsing SpyHttpServer URL: %s", err)
defer ts.Close()
sink := cogito.GitHubCommitStatusSink{
Log: hclog.NewNullLogger(),
Expand Down
4 changes: 2 additions & 2 deletions github/commitstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func (e *StatusError) Error() string {
return fmt.Sprintf("%s\n%s", e.What, e.Details)
}

// Default GitHub hostname
// GhDefaultHostname is the default GitHub hostname (used for git but not for the API)
const GhDefaultHostname = "github.com"

// API is the GitHub API endpoint.
// API is the default GitHub API hostname.
const API = "https://api.github.com"

type Target struct {
Expand Down
12 changes: 6 additions & 6 deletions testhelp/testhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,18 @@ func MakeGitRepoFromTestdata(
}

// SshRemote returns a GitHub SSH URL
func SshRemote(domain, owner, repo string) string {
return fmt.Sprintf("git@%s:%s/%s.git", domain, owner, repo)
func SshRemote(hostname, owner, repo string) string {
return fmt.Sprintf("git@%s:%s/%s.git", hostname, owner, repo)
}

// HttpsRemote returns a GitHub HTTPS URL
func HttpsRemote(domain, owner, repo string) string {
return fmt.Sprintf("https://%s/%s/%s.git", domain, owner, repo)
func HttpsRemote(hostname, owner, repo string) string {
return fmt.Sprintf("https://%s/%s/%s.git", hostname, owner, repo)
}

// HttpRemote returns a GitHub HTTP URL
func HttpRemote(domain, owner, repo string) string {
return fmt.Sprintf("http://%s/%s/%s.git", domain, owner, repo)
func HttpRemote(hostname, owner, repo string) string {
return fmt.Sprintf("http://%s/%s/%s.git", hostname, owner, repo)
}

// ToJSON returns the JSON encoding of thing.
Expand Down

0 comments on commit 66f1cf5

Please sign in to comment.