@@ -11,6 +11,12 @@ import (
11
11
"github.com/stretchr/testify/require"
12
12
)
13
13
14
+ // Helper function to call the runLint function with the new ignoreMissing parameter
15
+ func testRunLint (ctx context.Context , args []string , offline bool , lintKinds []string , output string , strict bool ) error {
16
+ // Default ignoreMissing to false for backward compatibility
17
+ return runLint (ctx , args , offline , lintKinds , output , strict , false )
18
+ }
19
+
14
20
func Test_OfflineLint (t * testing.T ) {
15
21
dir := t .TempDir ()
16
22
90
96
var fatal bool
91
97
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
92
98
93
- err = runLint (context .Background (), []string {workflowPath }, true , nil , "pretty" , true )
99
+ err = testRunLint (context .Background (), []string {workflowPath }, true , nil , "pretty" , true )
94
100
95
101
require .NoError (t , err )
96
102
assert .True (t , fatal , "should have exited" )
@@ -101,7 +107,7 @@ spec:
101
107
var fatal bool
102
108
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
103
109
104
- err = runLint (context .Background (), []string {workflowPath , clusterWftmplPath }, true , nil , "pretty" , true )
110
+ err = testRunLint (context .Background (), []string {workflowPath , clusterWftmplPath }, true , nil , "pretty" , true )
105
111
106
112
require .NoError (t , err )
107
113
assert .True (t , fatal , "should have exited" )
@@ -112,7 +118,7 @@ spec:
112
118
var fatal bool
113
119
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
114
120
115
- err = runLint (context .Background (), []string {workflowPath , wftmplPath }, true , nil , "pretty" , true )
121
+ err = testRunLint (context .Background (), []string {workflowPath , wftmplPath }, true , nil , "pretty" , true )
116
122
117
123
require .NoError (t , err )
118
124
assert .True (t , fatal , "should have exited" )
@@ -123,7 +129,7 @@ spec:
123
129
var fatal bool
124
130
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
125
131
126
- err = runLint (context .Background (), []string {wftmplPath }, true , nil , "pretty" , true )
132
+ err = testRunLint (context .Background (), []string {wftmplPath }, true , nil , "pretty" , true )
127
133
128
134
require .NoError (t , err )
129
135
assert .False (t , fatal , "should not have exited" )
@@ -134,7 +140,7 @@ spec:
134
140
var fatal bool
135
141
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
136
142
137
- err = runLint (context .Background (), []string {clusterWftmplPath }, true , nil , "pretty" , true )
143
+ err = testRunLint (context .Background (), []string {clusterWftmplPath }, true , nil , "pretty" , true )
138
144
139
145
require .NoError (t , err )
140
146
assert .False (t , fatal , "should not have exited" )
@@ -145,7 +151,7 @@ spec:
145
151
var fatal bool
146
152
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
147
153
148
- err = runLint (context .Background (), []string {workflowPath , wftmplPath , clusterWftmplPath }, true , nil , "pretty" , true )
154
+ err = testRunLint (context .Background (), []string {workflowPath , wftmplPath , clusterWftmplPath }, true , nil , "pretty" , true )
149
155
150
156
require .NoError (t , err )
151
157
assert .False (t , fatal , "should not have exited" )
@@ -156,7 +162,7 @@ spec:
156
162
var fatal bool
157
163
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
158
164
159
- err = runLint (context .Background (), []string {dir }, true , nil , "pretty" , true )
165
+ err = testRunLint (context .Background (), []string {dir }, true , nil , "pretty" , true )
160
166
161
167
require .NoError (t , err )
162
168
assert .False (t , fatal , "should not have exited" )
@@ -173,7 +179,7 @@ spec:
173
179
require .NoError (t , err )
174
180
defer func () { _ = os .Stdin .Close () }() // close previously opened path to avoid errors trying to remove the file.
175
181
176
- err = runLint (context .Background (), []string {workflowPath , wftmplPath , "-" }, true , nil , "pretty" , true )
182
+ err = testRunLint (context .Background (), []string {workflowPath , wftmplPath , "-" }, true , nil , "pretty" , true )
177
183
178
184
require .NoError (t , err )
179
185
assert .False (t , fatal , "should not have exited" )
@@ -205,7 +211,7 @@ spec:
205
211
var fatal bool
206
212
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
207
213
208
- err = runLint (context .Background (), []string {workflowCaseSensitivePath }, true , nil , "pretty" , true )
214
+ err = testRunLint (context .Background (), []string {workflowCaseSensitivePath }, true , nil , "pretty" , true )
209
215
210
216
require .NoError (t , err )
211
217
assert .True (t , fatal , "should have exited" )
@@ -216,7 +222,7 @@ spec:
216
222
var fatal bool
217
223
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
218
224
219
- err = runLint (context .Background (), []string {workflowCaseSensitivePath }, true , nil , "pretty" , false )
225
+ err = testRunLint (context .Background (), []string {workflowCaseSensitivePath }, true , nil , "pretty" , false )
220
226
221
227
require .NoError (t , err )
222
228
assert .False (t , fatal , "should not have exited" )
@@ -276,10 +282,21 @@ spec:
276
282
defer func () { logrus .StandardLogger ().ExitFunc = nil }()
277
283
var fatal bool
278
284
logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
279
- err = runLint (context .Background (), []string {workflowMultiDocsPath }, true , nil , "pretty" , false )
285
+ err = testRunLint (context .Background (), []string {workflowMultiDocsPath }, true , nil , "pretty" , false )
280
286
281
287
require .NoError (t , err )
282
288
assert .False (t , fatal , "should not have exited" )
283
289
})
284
290
291
+ t .Run ("linting a workflow with missing references and ignore-missing flag" , func (t * testing.T ) {
292
+ defer func () { logrus .StandardLogger ().ExitFunc = nil }()
293
+ var fatal bool
294
+ logrus .StandardLogger ().ExitFunc = func (int ) { fatal = true }
295
+
296
+ // Use the actual runLint function with ignoreMissing set to true
297
+ err = runLint (context .Background (), []string {workflowPath }, true , nil , "pretty" , true , true )
298
+
299
+ require .NoError (t , err )
300
+ assert .False (t , fatal , "should not have exited with ignore-missing flag" )
301
+ })
285
302
}
0 commit comments