mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 22:06:57 +00:00
fix test
This commit is contained in:
parent
dba083ac9c
commit
f5b3e2ccb0
1 changed files with 18 additions and 17 deletions
|
@ -23,26 +23,27 @@ func TestHandlerPerformance(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
testCase := func(uri string, status int) {
|
testCase := func(uri string, status int) {
|
||||||
req := httptest.NewRequest("GET", uri, nil)
|
t.Run(uri, func(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
req := httptest.NewRequest("GET", uri, nil)
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
log.Printf("Start: %v\n", time.Now())
|
log.Printf("Start: %v\n", time.Now())
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
testHandler(w, req)
|
testHandler(w, req)
|
||||||
end := time.Now()
|
end := time.Now()
|
||||||
log.Printf("Done: %v\n", time.Now())
|
log.Printf("Done: %v\n", time.Now())
|
||||||
|
|
||||||
resp := w.Result()
|
resp := w.Result()
|
||||||
|
|
||||||
if resp.StatusCode != status {
|
if resp.StatusCode != status {
|
||||||
t.Errorf("request failed with status code %d", resp.StatusCode)
|
t.Errorf("request failed with status code %d", resp.StatusCode)
|
||||||
} else {
|
} else {
|
||||||
t.Logf("request took %d milliseconds", end.Sub(start).Milliseconds())
|
t.Logf("request took %d milliseconds", end.Sub(start).Milliseconds())
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
testCase("https://mondstern.codeberg.page/", 424) // TODO: expect 200
|
testCase("https://mondstern.codeberg.page/", 404) // TODO: expect 200
|
||||||
testCase("https://mondstern.codeberg.page/", 424) // TODO: expect 200
|
testCase("https://codeberg.page/", 404) // TODO: expect 200
|
||||||
testCase("https://example.momar.xyz/", 424) // TODO: expect 200
|
testCase("https://example.momar.xyz/", 424)
|
||||||
testCase("https://codeberg.page/", 424) // TODO: expect 200
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue