This commit is contained in:
6543 2022-11-22 21:56:40 +01:00
parent dba083ac9c
commit f5b3e2ccb0
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE

View file

@ -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
} }