mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 21:32:46 +03:00
081a155cc1
(cherry picked from commitb7fe7cf401
) (cherry picked from commitcf339eed4f
) (cherry picked from commit4f3a16168b
) (cherry picked from commit6f5bbc53fc
) (cherry picked from commitaca42b422e
) (cherry picked from commit5a7f7580e5
) (cherry picked from commit06c383c807
) (cherry picked from commitfe831dcb53
) (cherry picked from commitcd12cd0dbc
) (cherry picked from commitcc79163703
) (cherry picked from commit0102a5715e
) (cherry picked from commit403f7520b3
) (cherry picked from commita3b61510a2
) (cherry picked from commitf83f0f9feb
) (cherry picked from commitfd1c3a6d09
) (cherry picked from commitf7cdc3d6f1
) (cherry picked from commit060121b644
) (cherry picked from commit62c847ff02
) (cherry picked from commit4d051b51c2
) (cherry picked from commit86e6981a93
) (cherry picked from commitc1fc9e441b
) (cherry picked from commit8bb2f0871a
) (cherry picked from commit0cd9fe5251
) (cherry picked from commitb0b44778b4
) (cherry picked from commit7c2f4f749f
)
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// SPDX-License-Identifier: MIT
|
|
|
|
package semver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestForgejoSemVerSetGet(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
ctx := db.DefaultContext
|
|
|
|
newVersion, err := version.NewVersion("v1.2.3")
|
|
assert.NoError(t, err)
|
|
assert.NoError(t, SetVersionString(ctx, newVersion.String()))
|
|
databaseVersion, err := GetVersion(ctx)
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, newVersion.String(), databaseVersion.String())
|
|
assert.True(t, newVersion.Equal(databaseVersion))
|
|
}
|
|
|
|
func TestForgejoSemVerMissing(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
ctx := db.DefaultContext
|
|
e := db.GetEngine(ctx)
|
|
|
|
_, err := e.Exec("delete from forgejo_sem_ver")
|
|
assert.NoError(t, err)
|
|
|
|
v, err := GetVersion(ctx)
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, "1.0.0", v.String())
|
|
|
|
_, err = e.Exec("drop table forgejo_sem_ver")
|
|
assert.NoError(t, err)
|
|
|
|
v, err = GetVersion(ctx)
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, "1.0.0", v.String())
|
|
}
|