mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 20:31:10 +00:00
32 lines
796 B
Go
32 lines
796 B
Go
|
package queue
|
||
|
|
||
|
import (
|
||
|
. "github.com/drone/drone/pkg/model"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func Test_getBuildUrl(t *testing.T) {
|
||
|
repo := &Repo{
|
||
|
Slug: "examplegit.com/owner/repo",
|
||
|
}
|
||
|
commit := &Commit{
|
||
|
Hash: "abc",
|
||
|
Branch: "example",
|
||
|
}
|
||
|
|
||
|
expected := "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=example"
|
||
|
output := getBuildUrl("http://examplehost.com", repo, commit)
|
||
|
|
||
|
if output != expected {
|
||
|
t.Errorf("Failed to build url. Expected: %s, got %s", expected, output)
|
||
|
}
|
||
|
|
||
|
commit.Branch = "url/unsafe/branch"
|
||
|
expected = "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=url%2Funsafe%2Fbranch"
|
||
|
output = getBuildUrl("http://examplehost.com", repo, commit)
|
||
|
|
||
|
if output != expected {
|
||
|
t.Errorf("Failed to build url. Expected: %s, got %s", expected, output)
|
||
|
}
|
||
|
}
|