Fixed "go vet" Failures

This commit is contained in:
Brad Rydzewski 2014-06-12 14:13:03 -07:00
parent 44ba19fd31
commit 0d340645b2
4 changed files with 12 additions and 27 deletions

View file

@ -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) {

View file

@ -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)
}
}

View file

@ -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 {

View file

@ -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)
}
}