refactor: export and move shared contexts into pkg/model (#931)

This commit moves the githubContext, jobContext and stepResult structs
from the runner package to the model package in preparation for #908
because the expression.go file lives in the runner package and would
introduce cyclic dependencies with the exprparser package.

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Björn Brauer
2021-12-22 20:52:09 +01:00
committed by GitHub
parent 558081242c
commit ed01f464ed
10 changed files with 132 additions and 124 deletions

View File

@@ -46,7 +46,7 @@ func createIfTestStepContext(t *testing.T, input string) *StepContext {
"ubuntu-latest": "ubuntu-latest",
},
},
StepResults: map[string]*stepResult{},
StepResults: map[string]*model.StepResult{},
Env: map[string]string{},
Run: &model.Run{
JobID: "job1",
@@ -71,14 +71,14 @@ func TestStepContextIsEnabled(t *testing.T) {
assertObject.True(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: success()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusSuccess,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusSuccess,
}
assertObject.True(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: success()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusFailure,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusFailure,
}
assertObject.False(sc.isEnabled(context.Background()))
@@ -87,14 +87,14 @@ func TestStepContextIsEnabled(t *testing.T) {
assertObject.False(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: failure()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusSuccess,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusSuccess,
}
assertObject.False(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: failure()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusFailure,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusFailure,
}
assertObject.True(sc.isEnabled(context.Background()))
@@ -103,14 +103,14 @@ func TestStepContextIsEnabled(t *testing.T) {
assertObject.True(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: always()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusSuccess,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusSuccess,
}
assertObject.True(sc.isEnabled(context.Background()))
sc = createIfTestStepContext(t, "if: always()")
sc.RunContext.StepResults["a"] = &stepResult{
Conclusion: stepStatusFailure,
sc.RunContext.StepResults["a"] = &model.StepResult{
Conclusion: model.StepStatusFailure,
}
assertObject.True(sc.isEnabled(context.Background()))
}