mirror of
1
Fork 0

chore: fix e2e

- Regression from #5948
- Use proper permission.
- Remove debug statement
This commit is contained in:
Gusted 2024-11-15 14:02:16 +01:00
parent 1e1b162cbe
commit 4a5d9d4b78
No known key found for this signature in database
GPG Key ID: FD821B732837125F
3 changed files with 12 additions and 3 deletions

View File

@ -8,6 +8,8 @@ import (
"net"
"net/http"
"net/url"
"os"
"regexp"
"testing"
"time"
@ -17,6 +19,8 @@ import (
"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) {
if len(prepare) == 0 || prepare[0] {
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)
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() {
require.NoError(t, os.WriteFile(setting.CustomConf, conf, 0o644))
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
s.Shutdown(ctx)
cancel()

View File

@ -83,10 +83,10 @@ func onGiteaRun[T testing.TB](t T, callback func(T, *url.URL)) {
// 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)), os.ModePerm))
require.NoError(t, os.WriteFile(setting.CustomConf, rootPathRe.ReplaceAll(conf, []byte("[repository]\nROOT = "+setting.RepoRootPath)), 0o600))
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)
s.Shutdown(ctx)
cancel()

View File

@ -201,7 +201,6 @@ func InitTest(requireGitea bool) {
if err != nil {
log.Fatal("os.ReadDir: %v", err)
}
fmt.Println(ownerDirs)
for _, ownerDir := range ownerDirs {
if !ownerDir.Type().IsDir() {