Skip to content

Commit f9a8b14

Browse files
committed
improve TestJobNeedsMatrix
1 parent 83d6eb0 commit f9a8b14

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

tests/integration/actions_job_test.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ jobs:
164164

165165
func TestJobNeedsMatrix(t *testing.T) {
166166
testCases := []struct {
167-
treePath string
168-
fileContent string
169-
execPolicies map[string]*taskExecPolicy
170-
expectedOutputs map[string]map[string]string // jobID(string) => output(map[string]string)
167+
treePath string
168+
fileContent string
169+
execPolicies map[string]*taskExecPolicy
170+
expectedTaskNeeds map[string]*runnerv1.TaskNeed // jobID => TaskNeed
171171
}{
172172
{
173173
treePath: ".gitea/workflows/jobs-outputs-with-matrix.yml",
@@ -224,11 +224,14 @@ jobs:
224224
},
225225
},
226226
},
227-
expectedOutputs: map[string]map[string]string{
227+
expectedTaskNeeds: map[string]*runnerv1.TaskNeed{
228228
"job1": {
229-
"output_1": "1",
230-
"output_2": "2",
231-
"output_3": "3",
229+
Result: runnerv1.Result_RESULT_SUCCESS,
230+
Outputs: map[string]string{
231+
"output_1": "1",
232+
"output_2": "2",
233+
"output_3": "3",
234+
},
232235
},
233236
},
234237
},
@@ -255,12 +258,12 @@ jobs:
255258
runner.execTask(t, task, policy)
256259
}
257260

258-
job2Task := runner.fetchTask(t)
259-
needs := job2Task.Needs
260-
assert.Len(t, needs, len(tc.expectedOutputs))
261-
for jobID, outputs := range tc.expectedOutputs {
262-
assert.Len(t, needs[jobID].Outputs, len(outputs))
263-
for outputKey, outputValue := range outputs {
261+
task := runner.fetchTask(t)
262+
needs := task.Needs
263+
assert.Len(t, needs, len(tc.expectedTaskNeeds))
264+
for jobID, tn := range tc.expectedTaskNeeds {
265+
assert.Len(t, needs[jobID].Outputs, len(tn.Outputs))
266+
for outputKey, outputValue := range tn.Outputs {
264267
assert.Equal(t, outputValue, needs[jobID].Outputs[outputKey])
265268
}
266269
}

0 commit comments

Comments
 (0)