Files
go-example/hello/hello_test.go
2026-01-02 17:04:48 +08:00

16 lines
329 B
Go

package hello
import (
"testing"
"net/http/httptest"
)
func TestHelloHandler(t *testing.T) {
w := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/hello", nil)
HelloHandler(w, req)
expected := "Hello, World!"
if w.Body.String() != expected {
t.Errorf("Expected %q but got %q", expected, w.Body.String())
}
}