mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-15 07:26:31 +03:00
967e04534e
Fix https://github.com/go-gitea/gitea/issues/32761#issuecomment-2540946064 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 42090844ed2de5e615abc6ece351c152d3344295) Conflicts: models/fixtures/action_run.yml models/fixtures/branch.yml routers/web/repo/actions/actions_test.go trivial context conflict
33 lines
847 B
Go
33 lines
847 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
actions_model "code.gitea.io/gitea/models/actions"
|
|
"code.gitea.io/gitea/models/db"
|
|
unittest "code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_loadIsRefDeleted(t *testing.T) {
|
|
unittest.PrepareTestEnv(t)
|
|
|
|
runs, total, err := db.FindAndCount[actions_model.ActionRun](db.DefaultContext,
|
|
actions_model.FindRunOptions{RepoID: 4, Ref: "refs/heads/test"})
|
|
require.NoError(t, err)
|
|
assert.Len(t, runs, 1)
|
|
assert.EqualValues(t, 1, total)
|
|
for _, run := range runs {
|
|
assert.False(t, run.IsRefDeleted)
|
|
}
|
|
|
|
require.NoError(t, loadIsRefDeleted(db.DefaultContext, 4, runs))
|
|
for _, run := range runs {
|
|
assert.True(t, run.IsRefDeleted)
|
|
}
|
|
}
|