-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_test.go
74 lines (61 loc) · 2.03 KB
/
view_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
package jenkins
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestViewServiceGet(t *testing.T) {
v, err := jenkins.Views().Get("all")
assert.Nil(t, err)
assert.NotNil(t, v)
assert.Equal(t, v.Name, "all")
}
func TestViewServiceCreate(t *testing.T) {
v, err := folder.Views().Get("testview")
assert.NotNil(t, err)
assert.Empty(t, v)
// create view
_, err = folder.Views().Create("testview", strings.NewReader(viewConf))
assert.Nil(t, err)
v, err = folder.Views().Get("testview")
assert.Nil(t, err)
assert.NotNil(t, v)
assert.Equal(t, v.Name, "testview")
assert.Equal(t, v.Description, "test")
// list views
views, err := folder.Views().List()
assert.Nil(t, err)
assert.Len(t, views, 2)
// // get job from view
// job, err := folder.Views.GetJobFromView("testview", pipeline.Name)
// assert.Nil(t, err)
// assert.Nil(t, job)
// // add job to view
// assert.Nil(t, folder.Views.AddJobToView("testview", pipeline.Name))
// job, err = folder.Views.GetJobFromView("testview", pipeline.Name)
// assert.Nil(t, err)
// assert.Equal(t, job.FullName, pipeline.FullName)
// jobs, err := folder.Views.ListJobInView("testview")
// assert.Nil(t, err)
// assert.Len(t, jobs, 1)
// // remove job from view
// assert.Nil(t, folder.Views.RemoveJobFromView("testview", pipeline.Name))
// jobs, err = folder.Views.ListJobInView("testview")
// assert.Nil(t, err)
// assert.Len(t, jobs, 0)
// // set description
// assert.Nil(t, folder.Views.SetDescription("testview", "new description"))
// v, err = folder.Views.Get("testview")
// assert.Nil(t, err)
// assert.Equal(t, v.Description, "new description")
// // set/get configuration
// assert.Nil(t, folder.Views.SetConfigure("testview", strings.ReplaceAll(viewConf, "test", "newtest")))
// config, err := folder.Views.GetConfigure("testview")
// assert.Nil(t, err)
// assert.Contains(t, config, "newtest")
// // delete view
// assert.Nil(t, folder.Views.Delete("testview"))
// v, err = folder.Views.Get("testview")
// assert.Nil(t, err)
// assert.Nil(t, v)
}