All checks were successful
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 3m7s
Build and Release / Lint (push) Successful in 5m21s
Build and Release / Unit Tests (push) Successful in 5m46s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 3m44s
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Successful in 4m4s
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Successful in 3m23s
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Successful in 3m47s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Successful in 8h6m28s
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitcaddy.com/server/models/db"
|
|
repo_model "code.gitcaddy.com/server/models/repo"
|
|
"code.gitcaddy.com/server/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUpdateRepoRunsNumbers(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
// update the number to a wrong one, the original is 3
|
|
_, err := db.GetEngine(t.Context()).ID(4).Cols("num_closed_action_runs").Update(&repo_model.Repository{
|
|
NumClosedActionRuns: 2,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
|
assert.Equal(t, 4, repo.NumActionRuns)
|
|
assert.Equal(t, 2, repo.NumClosedActionRuns)
|
|
|
|
// now update will correct them, only num_actionr_runs and num_closed_action_runs should be updated
|
|
err = UpdateRepoRunsNumbers(t.Context(), repo)
|
|
assert.NoError(t, err)
|
|
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
|
assert.Equal(t, 5, repo.NumActionRuns)
|
|
assert.Equal(t, 3, repo.NumClosedActionRuns)
|
|
}
|