aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration/integration_test.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-19 21:40:42 +0800
committerGitHub <noreply@github.com>2023-04-19 21:40:42 +0800
commite422342eebc18034ef586ec58f1e2fff0340091d (patch)
tree307264b46c1683915429083d54e9634ee4f2fc4d /tests/integration/integration_test.go
parent01214c8ada993bf5f54a4149979d140443d69410 (diff)
downloadgitea-e422342eebc18034ef586ec58f1e2fff0340091d.tar.gz
gitea-e422342eebc18034ef586ec58f1e2fff0340091d.zip
Allow adding new files to an empty repo (#24164)
![image](https://user-images.githubusercontent.com/2114189/232561612-2bfcfd0a-fc04-47ba-965f-5d0bcea46c54.png)
Diffstat (limited to 'tests/integration/integration_test.go')
-rw-r--r--tests/integration/integration_test.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go
index 965bae576c..33a815b154 100644
--- a/tests/integration/integration_test.go
+++ b/tests/integration/integration_test.go
@@ -124,6 +124,9 @@ func TestMain(m *testing.M) {
fmt.Printf("Error initializing test database: %v\n", err)
os.Exit(1)
}
+
+ // FIXME: the console logger is deleted by mistake, so if there is any `log.Fatal`, developers won't see any error message.
+ // Instead, "No tests were found", last nonsense log is "According to the configuration, subsequent logs will not be printed to the console"
exitCode := m.Run()
tests.WriterCloser.Reset()
@@ -366,10 +369,12 @@ const NoExpectedStatus = -1
func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.ResponseRecorder {
t.Helper()
recorder := httptest.NewRecorder()
+ if req.RemoteAddr == "" {
+ req.RemoteAddr = "test-mock:12345"
+ }
c.ServeHTTP(recorder, req)
if expectedStatus != NoExpectedStatus {
- if !assert.EqualValues(t, expectedStatus, recorder.Code,
- "Request: %s %s", req.Method, req.URL.String()) {
+ if !assert.EqualValues(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) {
logUnexpectedResponse(t, recorder)
}
}
@@ -410,8 +415,10 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
return
} else if len(respBytes) < 500 {
// if body is short, just log the whole thing
- t.Log("Response:", string(respBytes))
+ t.Log("Response: ", string(respBytes))
return
+ } else {
+ t.Log("Response length: ", len(respBytes))
}
// log the "flash" error message, if one exists