mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-29 12:46:16 +01:00
[F3] tests do not need a running Forgejo server
This commit is contained in:
parent
9eeeab7f8e
commit
b2b9749ac9
2 changed files with 44 additions and 51 deletions
|
@ -5,6 +5,7 @@ package forgejo
|
|||
import (
|
||||
"context"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
||||
|
@ -63,6 +64,9 @@ func runMirror(ctx context.Context, c *cli.Context, action cli.ActionFunc) error
|
|||
if err := git.InitSimple(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := models.Init(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return action(c)
|
||||
|
|
|
@ -4,14 +4,11 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/services/f3/driver"
|
||||
"code.gitea.io/gitea/services/migrations"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
f3_forges "lab.forgefriends.org/friendlyforgeformat/gof3/forges"
|
||||
|
@ -19,14 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func TestF3_CmdMirror_LocalForgejo(t *testing.T) {
|
||||
onGiteaRun(t, func(*testing.T, *url.URL) {
|
||||
defer test.MockVariableValue(&setting.F3.Enabled, true)()
|
||||
defer test.MockVariableValue(&setting.Migrations.AllowLocalNetworks, true)()
|
||||
// Gitea SDK (go-sdk) need to parse the AppVer from server response, so we must set it to a valid version string.
|
||||
defer test.MockVariableValue(&setting.AppVer, "1.16.0")
|
||||
// without migrations.Init() AllowLocalNetworks = true is not effective and
|
||||
// a http call fails with "...migration can only call allowed HTTP servers..."
|
||||
migrations.Init()
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
ctx := context.Background()
|
||||
var userID int64 = 700
|
||||
|
@ -68,5 +58,4 @@ func TestF3_CmdMirror_LocalForgejo(t *testing.T) {
|
|||
files := f3_util.Command(context.Background(), "find", dumpDir)
|
||||
assert.Contains(t, files, "/user/")
|
||||
assert.Contains(t, files, "/project/")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue