mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-25 08:03:41 +02:00
fix: Adjust the tests
Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
This commit is contained in:
@@ -95,7 +95,7 @@ labels:
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := yaml.Unmarshal([]byte(tt.content), tt.tmpl)
|
||||
if tt.wantErr != "" {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
assert.ErrorContains(t, err, tt.wantErr)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.want, tt.tmpl)
|
||||
|
||||
@@ -709,8 +709,8 @@ jobs:
|
||||
opts := getWorkflowCreateFileOptions(user2, apiRepo.DefaultBranch, "create "+tc.treePath, tc.fileContent)
|
||||
createWorkflowFile(t, token, user2.Name, apiRepo.Name, tc.treePath, opts)
|
||||
|
||||
// Execute the generate job first
|
||||
task := runner.fetchTask(t)
|
||||
// Execute the generate job first (use longer timeout for CI environments)
|
||||
task := runner.fetchTask(t, 10*time.Second)
|
||||
jobName := getTaskJobNameByTaskID(t, token, user2.Name, apiRepo.Name, task.Id)
|
||||
assert.Equal(t, "generate", jobName)
|
||||
outcome := tc.outcomes[jobName]
|
||||
@@ -721,7 +721,7 @@ jobs:
|
||||
// We expect 3 tasks for build (1), build (2), build (3)
|
||||
buildTasks := make([]int64, 0)
|
||||
for range 3 {
|
||||
buildTask := runner.fetchTask(t)
|
||||
buildTask := runner.fetchTask(t, 10*time.Second)
|
||||
buildJobName := getTaskJobNameByTaskID(t, token, user2.Name, apiRepo.Name, buildTask.Id)
|
||||
t.Logf("Fetched task: %s", buildJobName)
|
||||
assert.Contains(t, []string{"build (1)", "build (2)", "build (3)"}, buildJobName, "Expected a build job with matrix index")
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
pingv1 "code.gitea.io/actions-proto-go/ping/v1"
|
||||
"code.gitea.io/actions-proto-go/ping/v1/pingv1connect"
|
||||
@@ -94,7 +95,7 @@ func (r *mockRunner) registerAsRepoRunner(t *testing.T, ownerName, repoName, run
|
||||
|
||||
func (r *mockRunner) fetchTask(t *testing.T, timeout ...time.Duration) *runnerv1.Task {
|
||||
task := r.tryFetchTask(t, timeout...)
|
||||
assert.NotNil(t, task, "failed to fetch a task")
|
||||
require.NotNil(t, task, "failed to fetch a task")
|
||||
return task
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user