forked from kevadesu/forgejo
[UPGRADE] run sanity checks before the database is upgraded
(cherry picked from commit69741e4e66
) (cherry picked from commit2a3c7b09cb
) (cherry picked from commita1554c1168
) (cherry picked from commitedae2c6d2d
) (cherry picked from commit49737cf009
) (cherry picked from commitec53704c34
) (cherry picked from commit7a1c5c0f32
) (cherry picked from commite658c20c0f
) (cherry picked from commitbaf575468f
) (cherry picked from commit40cb14eff4
) (cherry picked from commit25ab4d0713
) (cherry picked from commit5a29005215
) (cherry picked from commitfef1260e99
) (cherry picked from commiteadbbb1afe
) (cherry picked from commitdb22d61eb4
) (cherry picked from commit9d3b0be39a
) (cherry picked from commitb3fa3c1292
)
This commit is contained in:
parent
31723651c9
commit
c8300d4fe2
4 changed files with 84 additions and 0 deletions
31
services/forgejo/sanity_test.go
Normal file
31
services/forgejo/sanity_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package forgejo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestForgejo_PreMigrationSanityChecks(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
ctx := db.DefaultContext
|
||||
e := db.GetEngine(ctx)
|
||||
|
||||
assert.NoError(t, PreMigrationSanityChecks(e, ForgejoV4DatabaseVersion, configFixture(t, "")))
|
||||
}
|
||||
|
||||
func configFixture(t *testing.T, content string) setting.ConfigProvider {
|
||||
config := filepath.Join(t.TempDir(), "app.ini")
|
||||
assert.NoError(t, os.WriteFile(config, []byte(content), 0o777))
|
||||
cfg, err := setting.NewConfigProviderFromFile(config)
|
||||
assert.NoError(t, err)
|
||||
return cfg
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue