9a5720e8ad
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Branch Cleanup / Delete merged branch (pull_request) Successful in 1s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Full namespace migration: update the Go module path and all import statements from git.mokoconsulting.tech to code.mokoconsulting.tech. Also updates all URL references in templates, workflows, configs, tests, and documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/db"
|
|
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/unittest"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/timeutil"
|
|
|
|
"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, 4, repo.NumActionRuns)
|
|
assert.Equal(t, 3, repo.NumClosedActionRuns)
|
|
}
|
|
|
|
func TestActionRun_Duration_NonNegative(t *testing.T) {
|
|
run := &ActionRun{
|
|
Started: timeutil.TimeStamp(100),
|
|
Stopped: timeutil.TimeStamp(200),
|
|
Status: StatusSuccess,
|
|
PreviousDuration: -time.Hour,
|
|
}
|
|
assert.Equal(t, time.Duration(0), run.Duration())
|
|
}
|