diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2025-05-19 19:47:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-19 19:47:57 -0700 |
commit | e32030f9fa98ff427ecdc157c7fccd10e1fd3d7f (patch) | |
tree | 886329f7d70f3c2283eeccb3ee5b1fa1c848ba6d /models/migrations/v1_23/v302_test.go | |
parent | cccd54999a6c3b9f2573d2ba20d83d7c4cac77c3 (diff) | |
download | gitea-release/v1.23.tar.gz gitea-release/v1.23.zip |
Add migrations tests (#34456) (#34498)release/v1.23
Fix #34455
Backport #34456
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/migrations/v1_23/v302_test.go')
-rw-r--r-- | models/migrations/v1_23/v302_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/models/migrations/v1_23/v302_test.go b/models/migrations/v1_23/v302_test.go new file mode 100644 index 0000000000..29e85ae9d9 --- /dev/null +++ b/models/migrations/v1_23/v302_test.go @@ -0,0 +1,51 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_23 //nolint + +import ( + "testing" + + "code.gitea.io/gitea/models/migrations/base" + "code.gitea.io/gitea/modules/timeutil" + + "github.com/stretchr/testify/assert" +) + +func Test_AddIndexToActionTaskStoppedLogExpired(t *testing.T) { + type ActionTask struct { + ID int64 + JobID int64 + Attempt int64 + RunnerID int64 `xorm:"index"` + Status int `xorm:"index"` + Started timeutil.TimeStamp `xorm:"index"` + Stopped timeutil.TimeStamp `xorm:"index(stopped_log_expired)"` + + RepoID int64 `xorm:"index"` + OwnerID int64 `xorm:"index"` + CommitSHA string `xorm:"index"` + IsForkPullRequest bool + + Token string `xorm:"-"` + TokenHash string `xorm:"UNIQUE"` // sha256 of token + TokenSalt string + TokenLastEight string `xorm:"index token_last_eight"` + + LogFilename string // file name of log + LogInStorage bool // read log from database or from storage + LogLength int64 // lines count + LogSize int64 // blob size + LogIndexes []int64 `xorm:"LONGBLOB"` // line number to offset + LogExpired bool `xorm:"index(stopped_log_expired)"` // files that are too old will be deleted + + Created timeutil.TimeStamp `xorm:"created"` + Updated timeutil.TimeStamp `xorm:"updated index"` + } + + // Prepare and load the testing database + x, deferable := base.PrepareTestEnv(t, 0, new(ActionTask)) + defer deferable() + + assert.NoError(t, AddIndexToActionTaskStoppedLogExpired(x)) +} |