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

Function TestServer_Shutdown

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

Source from the content-addressed store, hash-verified

93}
94
95func TestServer_Shutdown(t *testing.T) {
96 tests := []struct {
97 name string
98 server *Server
99 wantErr bool
100 }{
101 {
102 name: "shutdown nil server",
103 server: &Server{server: nil},
104 wantErr: false,
105 },
106 {
107 name: "shutdown running server",
108 server: &Server{server: &http.Server{Addr: ":0"}},
109 wantErr: false,
110 },
111 }
112
113 for _, tt := range tests {
114 t.Run(tt.name, func(t *testing.T) {
115 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
116 defer cancel()
117
118 err := tt.server.Shutdown(ctx)
119 if (err != nil) != tt.wantErr {
120 t.Errorf("Shutdown() error = %v, wantErr %v", err, tt.wantErr)
121 }
122 })
123 }
124}
125
126// mockTLSer is a mock implementation of TLSer for testing
127type mockTLSer struct {

Callers

nothing calls this directly

Calls 3

ErrorfMethod · 0.80
RunMethod · 0.65
ShutdownMethod · 0.45

Tested by

no test coverage detected