@@ -62,9 +62,12 @@ func TestDefaultPopularActions(t *testing.T) {
62
62
63
63
func TestReadWriteJSONL (t * testing.T ) {
64
64
files := []string {
65
- "test .jsonl" ,
65
+ "no_new_version .jsonl" ,
66
66
"skip_inputs.jsonl" ,
67
67
"skip_outputs.jsonl" ,
68
+ "skip_both.jsonl" ,
69
+ "skip_both.jsonl" ,
70
+ "outdated.jsonl" ,
68
71
}
69
72
70
73
for _ , file := range files {
@@ -98,16 +101,24 @@ func TestWriteGoToStdout(t *testing.T) {
98
101
want string
99
102
}{
100
103
{
101
- in : "test .jsonl" ,
102
- want : "want .go" ,
104
+ in : "no_new_version .jsonl" ,
105
+ want : "no_new_version .go" ,
103
106
},
104
107
{
105
108
in : "skip_inputs.jsonl" ,
106
- want : "skip_inputs_want .go" ,
109
+ want : "skip_inputs .go" ,
107
110
},
108
111
{
109
112
in : "skip_outputs.jsonl" ,
110
- want : "skip_outputs_want.go" ,
113
+ want : "skip_outputs.go" ,
114
+ },
115
+ {
116
+ in : "skip_both.jsonl" ,
117
+ want : "skip_both.go" ,
118
+ },
119
+ {
120
+ in : "outdated.jsonl" ,
121
+ want : "outdated.go" ,
111
122
},
112
123
}
113
124
@@ -135,7 +146,7 @@ func TestWriteGoToStdout(t *testing.T) {
135
146
}
136
147
137
148
func TestWriteJSONLFile (t * testing.T ) {
138
- in := filepath .Join ("testdata" , "actions" , "test .jsonl" )
149
+ in := filepath .Join ("testdata" , "actions" , "no_new_version .jsonl" )
139
150
b , err := os .ReadFile (in )
140
151
if err != nil {
141
152
panic (err )
@@ -164,7 +175,7 @@ func TestWriteJSONLFile(t *testing.T) {
164
175
}
165
176
166
177
func TestWriteGoFile (t * testing.T ) {
167
- in := filepath .Join ("testdata" , "actions" , "test .jsonl" )
178
+ in := filepath .Join ("testdata" , "actions" , "no_new_version .jsonl" )
168
179
out := filepath .Join ("testdata" , "go" , "out.go" )
169
180
defer os .Remove (out )
170
181
@@ -175,7 +186,7 @@ func TestWriteGoFile(t *testing.T) {
175
186
t .Fatal ("exit status is non-zero:" , status )
176
187
}
177
188
178
- b , err := os .ReadFile (filepath .Join ("testdata" , "go" , "want .go" ))
189
+ b , err := os .ReadFile (filepath .Join ("testdata" , "go" , "no_new_version .go" ))
179
190
if err != nil {
180
191
panic (err )
181
192
}
@@ -199,6 +210,7 @@ func TestFetchRemoteYAML(t *testing.T) {
199
210
}{
200
211
{"fetch.json" , "fetched.go" },
201
212
{"outdated.json" , "outdated.go" },
213
+ {"skip_both.json" , "skip_both.go" },
202
214
}
203
215
204
216
for _ , tc := range tests {
@@ -234,14 +246,18 @@ func TestWriteOutdatedActionAsJSONL(t *testing.T) {
234
246
t .Fatal ("exit status is non-zero:" , status )
235
247
}
236
248
237
- out := stdout .String ()
238
- if len (out ) > 0 {
239
- t .Fatalf ("empty output was expected but got %q" , out )
249
+ b , err := os .ReadFile (filepath .Join ("testdata" , "actions" , "outdated.jsonl" ))
250
+ if err != nil {
251
+ panic (err )
252
+ }
253
+ want , have := string (b ), stdout .String ()
254
+ if want != have {
255
+ t .Fatal (cmp .Diff (want , have ))
240
256
}
241
257
}
242
258
243
259
func TestLogOutput (t * testing.T ) {
244
- f := filepath .Join ("testdata" , "actions" , "test .jsonl" )
260
+ f := filepath .Join ("testdata" , "actions" , "no_new_version .jsonl" )
245
261
stdout := & bytes.Buffer {}
246
262
logged := & bytes.Buffer {}
247
263
status := newGen (stdout , io .Discard , logged ).run ([]string {"test" , "-s" , f , "-f" , "jsonl" })
@@ -357,7 +373,7 @@ func TestCouldNotReadJSONLFile(t *testing.T) {
357
373
}
358
374
359
375
func TestCouldNotCreateOutputFile (t * testing.T ) {
360
- f := filepath .Join ("testdata" , "actions" , "test .jsonl" )
376
+ f := filepath .Join ("testdata" , "actions" , "no_new_version .jsonl" )
361
377
out := filepath .Join ("testdata" , "this-dir-does-not-exit" , "foo.jsonl" )
362
378
stdout := io .Discard
363
379
stderr := & bytes.Buffer {}
@@ -382,7 +398,7 @@ func (w testErrorWriter) Write(b []byte) (int, error) {
382
398
func TestWriteError (t * testing.T ) {
383
399
for _ , format := range []string {"go" , "jsonl" } {
384
400
t .Run (format , func (t * testing.T ) {
385
- f := filepath .Join ("testdata" , "actions" , "test .jsonl" )
401
+ f := filepath .Join ("testdata" , "actions" , "no_new_version .jsonl" )
386
402
stdout := testErrorWriter {}
387
403
stderr := & bytes.Buffer {}
388
404
0 commit comments