MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / TestServer_Run_HTTP

Function TestServer_Run_HTTP

pkg/httpsrv/http_test.go:49–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestServer_Run_HTTP(t *testing.T) {
50 server := &http.Server{
51 Addr: "localhost:0", // Use port 0 for automatic port assignment
52 }
53
54 srv := New(server)
55
56 // Start server in background
57 ctx, cancel := context.WithCancel(context.Background())
58 defer cancel()
59
60 go func() {
61 _ = srv.Run()
62 }()
63
64 // Give server time to start
65 time.Sleep(200 * time.Millisecond)
66
67 // Test shutdown
68 shutdownCtx, shutdownCancel := context.WithTimeout(ctx, 2*time.Second)
69 defer shutdownCancel()
70
71 if err := srv.Shutdown(shutdownCtx); err != nil {
72 t.Errorf("Shutdown() error = %v", err)
73 }
74}
75
76func TestServer_Run_WithTLSer(t *testing.T) {
77 mockTLS := &mockTLSer{}

Callers

nothing calls this directly

Calls 4

ErrorfMethod · 0.80
NewFunction · 0.70
RunMethod · 0.65
ShutdownMethod · 0.45

Tested by

no test coverage detected