From 0d340645b24ea57c02e559b12c1c57898ceb80ac Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 12 Jun 2014 14:13:03 -0700 Subject: [PATCH] Fixed "go vet" Failures --- server/handler/commit.go | 2 -- shared/deploy/ssh_test.go | 4 ++-- shared/notify/slack.go | 2 +- shared/notify/slack_test.go | 31 +++++++++---------------------- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/server/handler/commit.go b/server/handler/commit.go index 271234838..030a8535f 100644 --- a/server/handler/commit.go +++ b/server/handler/commit.go @@ -161,8 +161,6 @@ func (h *CommitHandler) PostCommit(w http.ResponseWriter, r *http.Request) error // drop the items on the queue h.queue.Add(&queue.BuildTask{Repo: repo, Commit: c}) return nil - - return notImplemented{} } func (h *CommitHandler) Register(r *pat.Router) { diff --git a/shared/deploy/ssh_test.go b/shared/deploy/ssh_test.go index 89dba45c9..c672c1dae 100644 --- a/shared/deploy/ssh_test.go +++ b/shared/deploy/ssh_test.go @@ -82,7 +82,7 @@ func TestSSHOneArtifact(t *testing.T) { } if !strings.Contains(bscr, "ARTIFACT=build.result") { - t.Errorf("Expect script to contains artifact") + t.Error("Expect script to contains artifact") } if !strings.Contains(bscr, "scp -o StrictHostKeyChecking=no -P 2212 -r ${ARTIFACT} user@test.example.com:/srv/app/location") { @@ -101,7 +101,7 @@ func TestSSHMultiArtifact(t *testing.T) { } if !strings.Contains(bscr, "tar -cf ${ARTIFACT} build.result config/file") { - t.Errorf("Expect script to contains tar command. got:\n", bscr) + t.Errorf("Expect script to contains tar command. got: %s\n", bscr) } } diff --git a/shared/notify/slack.go b/shared/notify/slack.go index 1ae05e004..7fcd95e32 100644 --- a/shared/notify/slack.go +++ b/shared/notify/slack.go @@ -36,7 +36,7 @@ func (s *Slack) Send(context *Context) error { } func getBuildUrl(context *Context) string { - return fmt.Sprintf("%s/%s/%s/%s/branch/%s/commit/%s", context.Host, context.Repo.Remote, context.Repo.Owner, context.Repo.Name, context.Commit.Sha, context.Commit.Branch) + return fmt.Sprintf("%s/%s/%s/%s/branch/%s/commit/%s", context.Host, context.Repo.Host, context.Repo.Owner, context.Repo.Name, context.Commit.Branch, context.Commit.Sha) } func getMessage(context *Context, message string) string { diff --git a/shared/notify/slack_test.go b/shared/notify/slack_test.go index 887d355c9..4e8a2f617 100644 --- a/shared/notify/slack_test.go +++ b/shared/notify/slack_test.go @@ -1,41 +1,28 @@ package notify import ( - "github.com/drone/drone/pkg/model" + "github.com/drone/drone/server/resource/commit" + "github.com/drone/drone/server/resource/repo" "testing" ) func Test_getBuildUrl(t *testing.T) { c := &Context{ Host: "http://examplehost.com", - Repo: &model.Repo{ - Slug: "examplegit.com/owner/repo", + Repo: &repo.Repo{ + Host: "examplegit.com", + Owner: "owner", + Name: "repo", }, - Commit: &model.Commit{ - Hash: "abc", + Commit: &commit.Commit{ + Sha: "abc", Branch: "example", }, } - expected := "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=example" + expected := "http://examplehost.com/examplegit.com/owner/repo/branch/example/commit/abc" output := getBuildUrl(c) if output != expected { t.Errorf("Failed to build url. Expected: %s, got %s", expected, output) } - - c.Commit.Branch = "url/unsafe/branch" - expected = "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=url%2Funsafe%2Fbranch" - output = getBuildUrl(c) - - if output != expected { - t.Errorf("Failed to build url. Expected: %s, got %s", expected, output) - } - - c.Commit.Branch = "" - expected = "http://examplehost.com/examplegit.com/owner/repo/commit/abc?" - output = getBuildUrl(c) - - if output != expected { - t.Errorf("Failed to build url. Expected: %s, got %s", expected, output) - } }