forked from plouc/go-gitlab-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builds_test.go
84 lines (59 loc) · 1.87 KB
/
builds_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package gogitlab
import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
)
func TestProjectBuilds(t *testing.T) {
ts, gitlab := Stub("stubs/builds/list.json")
defer ts.Close()
builds, err := gitlab.ProjectBuilds("3")
assert.Nil(t, err)
assert.Equal(t, len(builds), 2)
assert.Equal(t, builds[0].ArtifactsFile.Filename, "artifacts.zip")
}
func TestProjectCommitBuilds(t *testing.T) {
ts, gitlab := Stub("stubs/builds/commit_builds_list.json")
defer ts.Close()
builds, err := gitlab.ProjectBuilds("3")
assert.Nil(t, err)
assert.Equal(t, len(builds), 2)
assert.Equal(t, builds[1].User.AvatarUrl, "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon")
}
func TestProjectBuild(t *testing.T) {
ts, gitlab := Stub("stubs/builds/build.json")
defer ts.Close()
build, err := gitlab.ProjectBuild("3", "12")
assert.Nil(t, err)
assert.Equal(t, build.Commit.Id, "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd")
}
func TestProjectCancelBuild(t *testing.T) {
ts, gitlab := Stub("stubs/builds/cancel.json")
defer ts.Close()
build, err := gitlab.ProjectBuild("3", "12")
assert.Nil(t, err)
assert.Equal(t, build.Status, "canceled")
}
func TestProjectRetryBuild(t *testing.T) {
ts, gitlab := Stub("stubs/builds/retry.json")
defer ts.Close()
build, err := gitlab.ProjectBuild("3", "12")
assert.Nil(t, err)
assert.Equal(t, build.Status, "pending")
}
func TestProjectEraseBuild(t *testing.T) {
ts, gitlab := Stub("stubs/builds/erase.json")
defer ts.Close()
build, err := gitlab.ProjectBuild("3", "12")
assert.Nil(t, err)
assert.Equal(t, build.Status, "failed")
}
func TestProjectArtifact(t *testing.T) {
ts, gitlab := Stub("stubs/builds/content.txt")
defer ts.Close()
r, err := gitlab.ProjectBuildArtifacts("3", "12")
assert.Nil(t, err)
defer r.Close()
contents, err := ioutil.ReadAll(r)
assert.Equal(t, string(contents), "a content")
}