Earl Warren
f6ba73de4c
Refs: https://forgejo.org/2023-08-release-v1-20-3-0/ (cherry picked from commit a266dd0ce3fca1296c6713ff1266f0065f0cd72b) (cherry picked from commit b9eb5eccd83e73ab6fb392557b7036063244f357) (cherry picked from commit 7fc2028ede6e3a576c3714b27940de9f871c33bd) (cherry picked from commit 0c988e612028eab277f03c16c0597da08c2c293a) (cherry picked from commit 7ba05e8c2b51c4c08ab3885f9014f7bdaf3d0f6b) (cherry picked from commit 2ed5068abe0cb57a257167d669faee207762b1d0) (cherry picked from commit 353913a26dd749f017cf8b76cf9218f68e8ca408) (cherry picked from commit 4e63a01a8bf9d0c8a1a6a6d7a3b18c64369bbaf1) (cherry picked from commit 99f612aed30852b23fe325bd5b6095aee9bd558e) (cherry picked from commit b4fe189caea9c656edd9c0c20e0d667911e4921c) (cherry picked from commit bd35e3b7bc2d64e649915c5103067be1c7ffbe44) (cherry picked from commit f59d9f7088af9963041eedc46fcce2ec8c9c4722) (cherry picked from commit 0b2a93e044b1d9319345ed2b6104a479eae376ef) (cherry picked from commit 8c5d8bfea0d65ebab33e2cb7dd04298d0f263fdd) (cherry picked from commit 2817ce027cbcd630d83484c98b9539a3a94a5266) (cherry picked from commit 162056cbcfd79710e4d81b1b36f650be291df832) (cherry picked from commit 07152a0ba640f71fa669ef84c473eb773a15ede9) (cherry picked from commit 72e37779159a1820bb2d02b4647967fed3c8abc2) (cherry picked from commit 3b1ebd95b94327b8056eed51e9c6dbb4c412af09) (cherry picked from commit 14fc4f3fac637fb026a64b6110026533caa11dfc) (cherry picked from commit 9052c86e8ce97895eec8642bdb1c987790924b03) (cherry picked from commit 16f1cc21ea518c5390061534c8cfcc8f9f0c2587) (cherry picked from commit 0fef12f5d85870fa364d6046ac04dcdfc8cb69df) (cherry picked from commit d187381f73a0859198aade34057c63aef38d764d) (cherry picked from commit 9dda7151116af3a0d52b0778eff0f837d6bd1cf5)
116 lines
2.7 KiB
Go
116 lines
2.7 KiB
Go
// SPDX-License-Identifier: MIT
|
|
|
|
package forgejo
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/models/forgejo/semver"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
"code.gitea.io/gitea/modules/log"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestForgejo_v1TOv5_0_1Included(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
logFatal = func(string, ...any) {}
|
|
defer func() {
|
|
logFatal = log.Fatal
|
|
}()
|
|
|
|
configWithSoragePath := `
|
|
[storage]
|
|
PATH = /something
|
|
`
|
|
verifyForgejoV1TOv5_0_1Included(t, configWithSoragePath, "[storage].PATH is set")
|
|
|
|
for _, c := range v1TOv5_0_1IncludedStorageSections {
|
|
config := fmt.Sprintf("[%s]\n[%s]\n", c.section, c.storageSection)
|
|
verifyForgejoV1TOv5_0_1Included(t, config, fmt.Sprintf("[%s] and [%s]", c.section, c.storageSection))
|
|
}
|
|
}
|
|
|
|
func verifyForgejoV1TOv5_0_1Included(t *testing.T, config, message string) {
|
|
ctx := db.DefaultContext
|
|
e := db.GetEngine(ctx)
|
|
|
|
for _, testCase := range []struct {
|
|
name string
|
|
dbVersion int64
|
|
semver string
|
|
config string
|
|
}{
|
|
{
|
|
name: "5.0.0 with no " + message,
|
|
dbVersion: ForgejoV5DatabaseVersion,
|
|
semver: "5.0.0+0-gitea-1.20.1",
|
|
config: "",
|
|
},
|
|
{
|
|
name: "5.0.1 with no " + message,
|
|
dbVersion: ForgejoV5DatabaseVersion,
|
|
semver: "5.0.1+0-gitea-1.20.2",
|
|
config: "",
|
|
},
|
|
{
|
|
name: "5.0.2 with " + message,
|
|
dbVersion: ForgejoV5DatabaseVersion,
|
|
semver: "5.0.2+0-gitea-1.20.3",
|
|
config: config,
|
|
},
|
|
{
|
|
name: "6.0.0 with " + message,
|
|
dbVersion: ForgejoV6DatabaseVersion,
|
|
semver: "6.0.0+0-gitea-1.21.0",
|
|
config: config,
|
|
},
|
|
} {
|
|
cfg := configFixture(t, testCase.config)
|
|
semver.SetVersionString(ctx, testCase.semver)
|
|
assert.NoError(t, v1TOv5_0_1Included(e, testCase.dbVersion, cfg))
|
|
}
|
|
|
|
for _, testCase := range []struct {
|
|
name string
|
|
dbVersion int64
|
|
semver string
|
|
config string
|
|
}{
|
|
{
|
|
name: "5.0.0 with " + message,
|
|
dbVersion: ForgejoV5DatabaseVersion,
|
|
semver: "5.0.0+0-gitea-1.20.1",
|
|
config: config,
|
|
},
|
|
{
|
|
name: "5.0.1 with " + message,
|
|
dbVersion: ForgejoV5DatabaseVersion,
|
|
semver: "5.0.1+0-gitea-1.20.2",
|
|
config: config,
|
|
},
|
|
{
|
|
//
|
|
// When upgrading from
|
|
//
|
|
// Forgejo >= 5.0.1+0-gitea-1.20.2
|
|
// Gitea > v1.21
|
|
//
|
|
// The version that the server was running prior to the upgrade
|
|
// is not available.
|
|
//
|
|
name: semver.DefaultVersionString + " with " + message,
|
|
dbVersion: ForgejoV4DatabaseVersion,
|
|
semver: semver.DefaultVersionString,
|
|
config: config,
|
|
},
|
|
} {
|
|
cfg := configFixture(t, testCase.config)
|
|
semver.SetVersionString(ctx, testCase.semver)
|
|
assert.ErrorContains(t, v1TOv5_0_1Included(e, testCase.dbVersion, cfg), message)
|
|
}
|
|
}
|