github.com/unclejack/drone@v0.2.1-0.20140918182345-831b034aa33b/pkg/queue/worker_test.go (about) 1 package queue 2 3 import ( 4 . "github.com/drone/drone/pkg/model" 5 "testing" 6 ) 7 8 func Test_getBuildUrl(t *testing.T) { 9 repo := &Repo{ 10 Slug: "examplegit.com/owner/repo", 11 } 12 commit := &Commit{ 13 Hash: "abc", 14 Branch: "example", 15 } 16 17 expected := "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=example" 18 output := getBuildUrl("http://examplehost.com", repo, commit) 19 20 if output != expected { 21 t.Errorf("Failed to build url. Expected: %s, got %s", expected, output) 22 } 23 24 commit.Branch = "url/unsafe/branch" 25 expected = "http://examplehost.com/examplegit.com/owner/repo/commit/abc?branch=url%2Funsafe%2Fbranch" 26 output = getBuildUrl("http://examplehost.com", repo, commit) 27 28 if output != expected { 29 t.Errorf("Failed to build url. Expected: %s, got %s", expected, output) 30 } 31 }