@@ -16,13 +16,19 @@ var (
16
16
)
17
17
18
18
func TestInit (t * testing.T ) {
19
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
20
+ return
21
+ }
19
22
ctx := context .Background ()
20
23
jenkins = CreateJenkins (nil , "http://localhost:8080" , "admin" , "admin" )
21
24
_ , err := jenkins .Init (ctx )
22
25
assert .Nil (t , err , "Jenkins Initialization should not fail" )
23
26
}
24
27
25
28
func TestCreateJobs (t * testing.T ) {
29
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
30
+ return
31
+ }
26
32
job1ID := "Job1_test"
27
33
job2ID := "job2_test"
28
34
job_data := getFileAsString ("job.xml" )
@@ -41,7 +47,9 @@ func TestCreateJobs(t *testing.T) {
41
47
}
42
48
43
49
func TestCreateNodes (t * testing.T ) {
44
-
50
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
51
+ return
52
+ }
45
53
id1 := "node1_test"
46
54
//id2 := "node2_test"
47
55
id3 := "node3_test"
@@ -64,6 +72,9 @@ func TestCreateNodes(t *testing.T) {
64
72
}
65
73
66
74
func TestDeleteNodes (t * testing.T ) {
75
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
76
+ return
77
+ }
67
78
id := "node4_test"
68
79
69
80
ctx := context .Background ()
@@ -72,6 +83,9 @@ func TestDeleteNodes(t *testing.T) {
72
83
}
73
84
74
85
func TestCreateBuilds (t * testing.T ) {
86
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
87
+ return
88
+ }
75
89
ctx := context .Background ()
76
90
jobs , _ := jenkins .GetAllJobs (ctx )
77
91
for _ , item := range jobs {
@@ -88,6 +102,9 @@ func TestCreateBuilds(t *testing.T) {
88
102
}
89
103
90
104
func TestGetQueueItem (t * testing.T ) {
105
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
106
+ return
107
+ }
91
108
ctx := context .Background ()
92
109
task , err := jenkins .GetQueueItem (ctx , queueID )
93
110
if err != nil {
@@ -99,6 +116,9 @@ func TestGetQueueItem(t *testing.T) {
99
116
}
100
117
101
118
func TestParseBuildHistory (t * testing.T ) {
119
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
120
+ return
121
+ }
102
122
r , err := os .Open ("_tests/build_history.txt" )
103
123
if err != nil {
104
124
panic (err )
@@ -108,6 +128,9 @@ func TestParseBuildHistory(t *testing.T) {
108
128
}
109
129
110
130
func TestCreateViews (t * testing.T ) {
131
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
132
+ return
133
+ }
111
134
ctx := context .Background ()
112
135
list_view , err := jenkins .CreateView (ctx , "test_list_view" , LIST_VIEW )
113
136
assert .Nil (t , err )
@@ -124,20 +147,29 @@ func TestCreateViews(t *testing.T) {
124
147
}
125
148
126
149
func TestGetAllJobs (t * testing.T ) {
150
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
151
+ return
152
+ }
127
153
ctx := context .Background ()
128
154
jobs , _ := jenkins .GetAllJobs (ctx )
129
155
assert .Equal (t , 2 , len (jobs ))
130
156
assert .Equal (t , jobs [0 ].Raw .Color , "blue" )
131
157
}
132
158
133
159
func TestGetAllNodes (t * testing.T ) {
160
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
161
+ return
162
+ }
134
163
ctx := context .Background ()
135
164
nodes , _ := jenkins .GetAllNodes (ctx )
136
165
assert .Equal (t , 3 , len (nodes ))
137
166
assert .Equal (t , nodes [0 ].GetName (), "master" )
138
167
}
139
168
140
169
func TestGetAllBuilds (t * testing.T ) {
170
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
171
+ return
172
+ }
141
173
ctx := context .Background ()
142
174
builds , _ := jenkins .GetAllBuildIds (ctx , "Job1_test" )
143
175
for _ , b := range builds {
@@ -148,6 +180,9 @@ func TestGetAllBuilds(t *testing.T) {
148
180
}
149
181
150
182
func TestGetLabel (t * testing.T ) {
183
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
184
+ return
185
+ }
151
186
ctx := context .Background ()
152
187
label , err := jenkins .GetLabel (ctx , "test_label" )
153
188
assert .Nil (t , err )
@@ -174,6 +209,12 @@ func TestGetLabel(t *testing.T) {
174
209
}
175
210
176
211
func TestBuildMethods (t * testing.T ) {
212
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
213
+ return
214
+ }
215
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
216
+ return
217
+ }
177
218
ctx := context .Background ()
178
219
job , _ := jenkins .GetJob (ctx , "Job1_test" )
179
220
build , _ := job .GetLastBuild (ctx )
@@ -182,6 +223,12 @@ func TestBuildMethods(t *testing.T) {
182
223
}
183
224
184
225
func TestGetSingleJob (t * testing.T ) {
226
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
227
+ return
228
+ }
229
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
230
+ return
231
+ }
185
232
ctx := context .Background ()
186
233
job , _ := jenkins .GetJob (ctx , "Job1_test" )
187
234
isRunning , _ := job .IsRunning (ctx )
@@ -192,6 +239,9 @@ func TestGetSingleJob(t *testing.T) {
192
239
}
193
240
194
241
func TestEnableDisableJob (t * testing.T ) {
242
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
243
+ return
244
+ }
195
245
ctx := context .Background ()
196
246
job , _ := jenkins .GetJob (ctx , "Job1_test" )
197
247
result , _ := job .Disable (ctx )
@@ -201,6 +251,9 @@ func TestEnableDisableJob(t *testing.T) {
201
251
}
202
252
203
253
func TestCopyDeleteJob (t * testing.T ) {
254
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
255
+ return
256
+ }
204
257
ctx := context .Background ()
205
258
job , _ := jenkins .GetJob (ctx , "Job1_test" )
206
259
jobCopy , _ := job .Copy (ctx , "Job1_test_copy" )
@@ -210,19 +263,28 @@ func TestCopyDeleteJob(t *testing.T) {
210
263
}
211
264
212
265
func TestGetPlugins (t * testing.T ) {
266
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
267
+ return
268
+ }
213
269
ctx := context .Background ()
214
270
plugins , _ := jenkins .GetPlugins (ctx , 3 )
215
271
assert .Equal (t , 10 , plugins .Count ())
216
272
}
217
273
218
274
func TestGetViews (t * testing.T ) {
275
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
276
+ return
277
+ }
219
278
ctx := context .Background ()
220
279
views , _ := jenkins .GetAllViews (ctx )
221
280
assert .Equal (t , len (views ), 3 )
222
281
assert .Equal (t , len (views [0 ].Raw .Jobs ), 2 )
223
282
}
224
283
225
284
func TestGetSingleView (t * testing.T ) {
285
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
286
+ return
287
+ }
226
288
ctx := context .Background ()
227
289
view , _ := jenkins .GetView (ctx , "All" )
228
290
view2 , _ := jenkins .GetView (ctx , "test_list_view" )
@@ -232,6 +294,9 @@ func TestGetSingleView(t *testing.T) {
232
294
}
233
295
234
296
func TestCreateFolder (t * testing.T ) {
297
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
298
+ return
299
+ }
235
300
ctx := context .Background ()
236
301
folder1ID := "folder1_test"
237
302
folder2ID := "folder2_test"
@@ -248,6 +313,9 @@ func TestCreateFolder(t *testing.T) {
248
313
}
249
314
250
315
func TestCreateJobInFolder (t * testing.T ) {
316
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
317
+ return
318
+ }
251
319
ctx := context .Background ()
252
320
jobName := "Job_test"
253
321
job_data := getFileAsString ("job.xml" )
@@ -266,6 +334,9 @@ func TestCreateJobInFolder(t *testing.T) {
266
334
}
267
335
268
336
func TestGetFolder (t * testing.T ) {
337
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
338
+ return
339
+ }
269
340
ctx := context .Background ()
270
341
folder1ID := "folder1_test"
271
342
folder2ID := "folder2_test"
@@ -281,6 +352,9 @@ func TestGetFolder(t *testing.T) {
281
352
assert .Equal (t , folder2ID , folder2 .GetName ())
282
353
}
283
354
func TestInstallPlugin (t * testing.T ) {
355
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
356
+ return
357
+ }
284
358
ctx := context .Background ()
285
359
286
360
err := jenkins .InstallPlugin (ctx , "packer" , "1.4" )
@@ -289,6 +363,9 @@ func TestInstallPlugin(t *testing.T) {
289
363
}
290
364
291
365
func TestConcurrentRequests (t * testing.T ) {
366
+ if _ , ok := os .LookupEnv (integration_test ); ! ok {
367
+ return
368
+ }
292
369
ctx := context .Background ()
293
370
for i := 0 ; i <= 16 ; i ++ {
294
371
go func () {
0 commit comments