mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-31 18:30:58 +00:00
chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844)
<!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/844): <!--number 844 --><!--line 0 --><!--description Y2hvcmU6IHVzZSB0LkNvbnRleHQgZm9yIHRlc3RzLCBhY3RpdmF0ZSB1c2V0ZXN0aW5nIGZvciBsaW50ICsgYWRkIHQuVGVtcERpciBhbmQgdC5DaGRpciBbc2tpcCBjYXNjYWRlXQ==-->chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir [skip cascade]<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/844 Reviewed-by: Gusted <gusted@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
66bb63ea18
commit
0520ff4e05
22 changed files with 126 additions and 153 deletions
|
@ -1,7 +1,6 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"code.forgejo.org/forgejo/runner/v9/act/exprparser"
|
||||
|
@ -76,7 +75,7 @@ func createRunContext(t *testing.T) *RunContext {
|
|||
|
||||
func TestExpressionEvaluateRunContext(t *testing.T) {
|
||||
rc := createRunContext(t)
|
||||
ee := rc.NewExpressionEvaluator(context.Background())
|
||||
ee := rc.NewExpressionEvaluator(t.Context())
|
||||
|
||||
tables := []struct {
|
||||
in string
|
||||
|
@ -137,7 +136,7 @@ func TestExpressionEvaluateRunContext(t *testing.T) {
|
|||
table := table
|
||||
t.Run(table.in, func(t *testing.T) {
|
||||
assertObject := assert.New(t)
|
||||
out, err := ee.evaluate(context.Background(), table.in, exprparser.DefaultStatusCheckNone)
|
||||
out, err := ee.evaluate(t.Context(), table.in, exprparser.DefaultStatusCheckNone)
|
||||
if table.errMesg == "" {
|
||||
assertObject.NoError(err, table.in)
|
||||
assertObject.Equal(table.out, out, table.in)
|
||||
|
@ -155,7 +154,7 @@ func TestExpressionEvaluateStep(t *testing.T) {
|
|||
RunContext: rc,
|
||||
}
|
||||
|
||||
ee := rc.NewStepExpressionEvaluator(context.Background(), step)
|
||||
ee := rc.NewStepExpressionEvaluator(t.Context(), step)
|
||||
|
||||
tables := []struct {
|
||||
in string
|
||||
|
@ -177,7 +176,7 @@ func TestExpressionEvaluateStep(t *testing.T) {
|
|||
table := table
|
||||
t.Run(table.in, func(t *testing.T) {
|
||||
assertObject := assert.New(t)
|
||||
out, err := ee.evaluate(context.Background(), table.in, exprparser.DefaultStatusCheckNone)
|
||||
out, err := ee.evaluate(t.Context(), table.in, exprparser.DefaultStatusCheckNone)
|
||||
if table.errMesg == "" {
|
||||
assertObject.NoError(err, table.in)
|
||||
assertObject.Equal(table.out, out, table.in)
|
||||
|
@ -217,7 +216,7 @@ func TestExpressionInterpolate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
ee := rc.NewExpressionEvaluator(context.Background())
|
||||
ee := rc.NewExpressionEvaluator(t.Context())
|
||||
tables := []struct {
|
||||
in string
|
||||
out string
|
||||
|
@ -260,7 +259,7 @@ func TestExpressionInterpolate(t *testing.T) {
|
|||
table := table
|
||||
t.Run("interpolate", func(t *testing.T) {
|
||||
assertObject := assert.New(t)
|
||||
out := ee.Interpolate(context.Background(), table.in)
|
||||
out := ee.Interpolate(t.Context(), table.in)
|
||||
assertObject.Equal(table.out, out, table.in)
|
||||
})
|
||||
}
|
||||
|
@ -287,7 +286,7 @@ func TestExpressionRewriteSubExpression(t *testing.T) {
|
|||
for _, table := range table {
|
||||
t.Run("TestRewriteSubExpression", func(t *testing.T) {
|
||||
assertObject := assert.New(t)
|
||||
out, err := rewriteSubExpression(context.Background(), table.in, false)
|
||||
out, err := rewriteSubExpression(t.Context(), table.in, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ func TestExpressionRewriteSubExpressionForceFormat(t *testing.T) {
|
|||
for _, table := range table {
|
||||
t.Run("TestRewriteSubExpressionForceFormat", func(t *testing.T) {
|
||||
assertObject := assert.New(t)
|
||||
out, err := rewriteSubExpression(context.Background(), table.in, true)
|
||||
out, err := rewriteSubExpression(t.Context(), table.in, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue