summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/actions/actions_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/repo/actions/actions_test.go')
-rw-r--r--routers/web/repo/actions/actions_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/routers/web/repo/actions/actions_test.go b/routers/web/repo/actions/actions_test.go
new file mode 100644
index 0000000000..939c4aaf57
--- /dev/null
+++ b/routers/web/repo/actions/actions_test.go
@@ -0,0 +1,33 @@
+// 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)
+ }
+}