test: check and handle error for testing

This commit is contained in:
2026-01-26 18:55:59 +07:00
parent 6def82a095
commit a3f6baa6ae
17 changed files with 505 additions and 516 deletions
+8 -4
View File
@@ -46,7 +46,8 @@ func TestHTTPSServer_Listen(t *testing.T) {
return
}
assert.NotNil(t, listener)
listener.Close()
err = listener.Close()
assert.NoError(t, err)
}
func TestHTTPSServer_Serve(t *testing.T) {
@@ -62,7 +63,8 @@ func TestHTTPSServer_Serve(t *testing.T) {
go func() {
time.Sleep(100 * time.Millisecond)
listener.Close()
err = listener.Close()
assert.NoError(t, err)
}()
err = srv.Serve(listener)
@@ -111,6 +113,8 @@ func TestHTTPSServer_Serve_Success(t *testing.T) {
_, _ = conn.Write([]byte("GET / HTTP/1.1\r\nHost: ping.example.com\r\n\r\n"))
time.Sleep(100 * time.Millisecond)
conn.Close()
listener.Close()
err = conn.Close()
assert.NoError(t, err)
err = listener.Close()
assert.NoError(t, err)
}