add just more dag tests (#3083)

This commit is contained in:
6543 2023-12-30 16:45:11 +01:00 committed by GitHub
parent c74dc9ce92
commit 2cb7669413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,4 +79,73 @@ func TestConvertDAGToStages(t *testing.T) {
} }
_, err = convertDAGToStages(steps, "") _, err = convertDAGToStages(steps, "")
assert.ErrorIs(t, err, &ErrStepMissingDependency{}) assert.ErrorIs(t, err, &ErrStepMissingDependency{})
steps = map[string]*dagCompilerStep{
"echo env": {
position: 0,
name: "echo env",
group: "",
step: &backend_types.Step{
Name: "test_step_0",
UUID: "01HJDPEW6R7J0JBE3F1T7Q0TYX",
Type: "commands",
Alias: "echo env",
Image: "bash",
},
},
"echo 1": {
position: 1,
name: "echo 1",
group: "",
dependsOn: []string{"echo env", "echo 2"},
step: &backend_types.Step{
Name: "test_step_1",
UUID: "01HJDPF770QGRZER8RF79XVS4M",
Type: "commands",
Alias: "echo 1",
Image: "bash",
},
},
"echo 2": {
position: 2,
name: "echo 2",
group: "",
step: &backend_types.Step{
Name: "test_step_2",
UUID: "01HJDPFF5RMEYZW0YTGR1Y1ZR0",
Type: "commands",
Alias: "echo 2",
Image: "bash",
},
},
}
stages, err := convertDAGToStages(steps, "test")
assert.NoError(t, err)
assert.EqualValues(t, []*backend_types.Stage{{
Name: "test_stage_0",
Alias: "test_stage_0",
Steps: []*backend_types.Step{{
Name: "test_step_0",
UUID: "01HJDPEW6R7J0JBE3F1T7Q0TYX",
Type: "commands",
Alias: "echo env",
Image: "bash",
}, {
Name: "test_step_2",
UUID: "01HJDPFF5RMEYZW0YTGR1Y1ZR0",
Type: "commands",
Alias: "echo 2",
Image: "bash",
}},
}, {
Name: "test_stage_1",
Alias: "test_stage_1",
Steps: []*backend_types.Step{{
Name: "test_step_1",
UUID: "01HJDPF770QGRZER8RF79XVS4M",
Type: "commands",
Alias: "echo 1",
Image: "bash",
}},
}}, stages)
} }