mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-07 22:29:02 +00:00
ac49dbe1a2
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
38 lines
892 B
Go
38 lines
892 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_28
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modelmigration/migrationtest"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAddMaxParallelToActionRunJob(t *testing.T) {
|
|
type ActionRunJob struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
Name string `xorm:"VARCHAR(255)"`
|
|
}
|
|
|
|
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ActionRunJob))
|
|
defer deferable()
|
|
if x == nil || t.Failed() {
|
|
return
|
|
}
|
|
|
|
_, err := x.Insert(&ActionRunJob{Name: "job-a"})
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, AddMaxParallelToActionRunJob(t.Context(), x))
|
|
|
|
// pre-existing rows must default to unlimited
|
|
var maxParallel int
|
|
has, err := x.SQL("SELECT max_parallel FROM action_run_job WHERE id = ?", 1).Get(&maxParallel)
|
|
require.NoError(t, err)
|
|
require.True(t, has)
|
|
require.Equal(t, 0, maxParallel)
|
|
}
|