mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 21:31:02 +00:00
Fixed "go vet" Failures
This commit is contained in:
parent
44ba19fd31
commit
0d340645b2
4 changed files with 12 additions and 27 deletions
|
@ -161,8 +161,6 @@ func (h *CommitHandler) PostCommit(w http.ResponseWriter, r *http.Request) error
|
||||||
// drop the items on the queue
|
// drop the items on the queue
|
||||||
h.queue.Add(&queue.BuildTask{Repo: repo, Commit: c})
|
h.queue.Add(&queue.BuildTask{Repo: repo, Commit: c})
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
return notImplemented{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *CommitHandler) Register(r *pat.Router) {
|
func (h *CommitHandler) Register(r *pat.Router) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ func TestSSHOneArtifact(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(bscr, "ARTIFACT=build.result") {
|
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") {
|
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") {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (s *Slack) Send(context *Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBuildUrl(context *Context) string {
|
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 {
|
func getMessage(context *Context, message string) string {
|
||||||
|
|
|
@ -1,41 +1,28 @@
|
||||||
package notify
|
package notify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/drone/drone/pkg/model"
|
"github.com/drone/drone/server/resource/commit"
|
||||||
|
"github.com/drone/drone/server/resource/repo"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_getBuildUrl(t *testing.T) {
|
func Test_getBuildUrl(t *testing.T) {
|
||||||
c := &Context{
|
c := &Context{
|
||||||
Host: "http://examplehost.com",
|
Host: "http://examplehost.com",
|
||||||
Repo: &model.Repo{
|
Repo: &repo.Repo{
|
||||||
Slug: "examplegit.com/owner/repo",
|
Host: "examplegit.com",
|
||||||
|
Owner: "owner",
|
||||||
|
Name: "repo",
|
||||||
},
|
},
|
||||||
Commit: &model.Commit{
|
Commit: &commit.Commit{
|
||||||
Hash: "abc",
|
Sha: "abc",
|
||||||
Branch: "example",
|
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)
|
output := getBuildUrl(c)
|
||||||
|
|
||||||
if output != expected {
|
if output != expected {
|
||||||
t.Errorf("Failed to build url. Expected: %s, got %s", expected, output)
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue