2023-08-09 00:05:06 +02:00
|
|
|
// 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"
|
|
|
|
|
2024-07-30 21:41:10 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-08-09 00:05:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestForgejo_PreMigrationSanityChecks(t *testing.T) {
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
2023-08-09 00:05:06 +02:00
|
|
|
ctx := db.DefaultContext
|
|
|
|
e := db.GetEngine(ctx)
|
|
|
|
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, PreMigrationSanityChecks(e, ForgejoV4DatabaseVersion, configFixture(t, "")))
|
2023-08-09 00:05:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func configFixture(t *testing.T, content string) setting.ConfigProvider {
|
|
|
|
config := filepath.Join(t.TempDir(), "app.ini")
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, os.WriteFile(config, []byte(content), 0o777))
|
2023-08-09 00:05:06 +02:00
|
|
|
cfg, err := setting.NewConfigProviderFromFile(config)
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, err)
|
2023-08-09 00:05:06 +02:00
|
|
|
return cfg
|
|
|
|
}
|