mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-03 09:04:17 +00:00
fff32e9469
Migrations should never use model structs directly, because the model structs can be different in different releases. e.g. if one migration uses "User" model, it works in the early releases, then one day, when the User model changes, the migration breaks because it will use the new (incorrect) User model, it should only use the old User model. The same to "modules/structs". --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
37 lines
855 B
Go
37 lines
855 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_27
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modelmigration/migrationtest"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAddCancellingSupportToActionRunner(t *testing.T) {
|
|
type ActionRunner struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
Name string
|
|
}
|
|
|
|
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ActionRunner))
|
|
defer deferable()
|
|
if x == nil || t.Failed() {
|
|
return
|
|
}
|
|
|
|
_, err := x.Insert(&ActionRunner{Name: "runner"})
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, AddCancellingSupportToActionRunner(x))
|
|
|
|
var hasCancellingSupport bool
|
|
has, err := x.SQL("SELECT has_cancelling_support FROM action_runner WHERE id = ?", 1).Get(&hasCancellingSupport)
|
|
require.NoError(t, err)
|
|
require.True(t, has)
|
|
require.False(t, hasCancellingSupport)
|
|
}
|