srs/trunk/research/httpmock/main_test.go
Winlin b39aae1447 AI: Cover protocol HTTP/HTTPS/RTMP/RTC by utests. (#4493)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-16 22:21:07 -04:00

25 lines
464 B
Go

package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestHttpMock(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
}))
defer s.Close()
resp, err := http.Get(s.URL)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode)
}
}