-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathjenkins_test.go
43 lines (35 loc) · 990 Bytes
/
jenkins_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseJobPath(t *testing.T) {
auth := &Auth{
Username: "appleboy",
Token: "1234",
}
jenkins := NewJenkins(auth, "http://example.com", false)
assert.Equal(t, "/job/foo", jenkins.parseJobPath("/foo/"))
assert.Equal(t, "/job/foo", jenkins.parseJobPath("foo/"))
assert.Equal(t, "/job/foo/job/bar", jenkins.parseJobPath("foo/bar"))
assert.Equal(t, "/job/foo/job/bar", jenkins.parseJobPath("foo///bar"))
}
func TestUnSupportProtocol(t *testing.T) {
auth := &Auth{
Username: "foo",
Token: "bar",
}
jenkins := NewJenkins(auth, "example.com", false)
err := jenkins.trigger("drone-jenkins", nil)
assert.NotNil(t, err)
}
func TestTriggerBuild(t *testing.T) {
auth := &Auth{
Username: "foo",
Token: "bar",
}
jenkins := NewJenkins(auth, "http://example.com", false)
err := jenkins.trigger("drone-jenkins", url.Values{"token": []string{"bar"}})
assert.Nil(t, err)
}