mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 23:42:28 +00:00
Merge pull request 'chore: fix e2e' (#5977) from gusted/fix-e2e into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5977 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
commit
b21cc70dd7
|
@ -8,6 +8,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -17,6 +19,8 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var rootPathRe = regexp.MustCompile("\\[repository\\]\nROOT\\s=\\s.*")
|
||||||
|
|
||||||
func onForgejoRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare ...bool) {
|
func onForgejoRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare ...bool) {
|
||||||
if len(prepare) == 0 || prepare[0] {
|
if len(prepare) == 0 || prepare[0] {
|
||||||
defer tests.PrepareTestEnv(t, 1)()
|
defer tests.PrepareTestEnv(t, 1)()
|
||||||
|
@ -37,7 +41,13 @@ func onForgejoRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare .
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
u.Host = listener.Addr().String()
|
u.Host = listener.Addr().String()
|
||||||
|
|
||||||
|
// Override repository root in config.
|
||||||
|
conf, err := os.ReadFile(setting.CustomConf)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, os.WriteFile(setting.CustomConf, rootPathRe.ReplaceAll(conf, []byte("[repository]\nROOT = "+setting.RepoRootPath)), 0o644))
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
require.NoError(t, os.WriteFile(setting.CustomConf, conf, 0o644))
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
s.Shutdown(ctx)
|
s.Shutdown(ctx)
|
||||||
cancel()
|
cancel()
|
||||||
|
|
|
@ -83,10 +83,10 @@ func onGiteaRun[T testing.TB](t T, callback func(T, *url.URL)) {
|
||||||
// Override repository root in config.
|
// Override repository root in config.
|
||||||
conf, err := os.ReadFile(setting.CustomConf)
|
conf, err := os.ReadFile(setting.CustomConf)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, os.WriteFile(setting.CustomConf, rootPathRe.ReplaceAll(conf, []byte("[repository]\nROOT = "+setting.RepoRootPath)), os.ModePerm))
|
require.NoError(t, os.WriteFile(setting.CustomConf, rootPathRe.ReplaceAll(conf, []byte("[repository]\nROOT = "+setting.RepoRootPath)), 0o600))
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
require.NoError(t, os.WriteFile(setting.CustomConf, conf, os.ModePerm))
|
require.NoError(t, os.WriteFile(setting.CustomConf, conf, 0o600))
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||||
s.Shutdown(ctx)
|
s.Shutdown(ctx)
|
||||||
cancel()
|
cancel()
|
||||||
|
|
|
@ -201,7 +201,6 @@ func InitTest(requireGitea bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("os.ReadDir: %v", err)
|
log.Fatal("os.ReadDir: %v", err)
|
||||||
}
|
}
|
||||||
fmt.Println(ownerDirs)
|
|
||||||
|
|
||||||
for _, ownerDir := range ownerDirs {
|
for _, ownerDir := range ownerDirs {
|
||||||
if !ownerDir.Type().IsDir() {
|
if !ownerDir.Type().IsDir() {
|
||||||
|
|
Loading…
Reference in a new issue