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

Function TestTLSAutoEncryptConfig_Run

pkg/httpsrv/tls_auto_encrypt_test.go:138–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestTLSAutoEncryptConfig_Run(t *testing.T) {
139 config := NewTLSEAutoEncryptConfig("example.com", "admin@example.com",
140 WithTLSEncryptEnableRedirect("localhost:0"))
141
142 if err := config.Validate(); err != nil {
143 t.Fatalf("Validate() failed: %v", err)
144 }
145
146 // Create a test server that will immediately shut down
147 server := &http.Server{
148 Addr: "localhost:0",
149 }
150
151 // Test should complete quickly since the server can't actually start TLS
152 // in test environment without proper certificates
153 done := make(chan error, 1)
154 go func() {
155 done <- config.Run(server)
156 }()
157
158 // Give it a moment then shutdown
159 time.Sleep(200 * time.Millisecond)
160 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
161 defer cancel()
162 server.Shutdown(ctx)
163
164 // Wait for Run to complete
165 select {
166 case err := <-done:
167 if err != nil && err != http.ErrServerClosed {
168 t.Logf("Run() returned expected error in test environment: %v", err)
169 }
170 case <-time.After(3 * time.Second):
171 t.Error("Run() timed out")
172 }
173}

Callers

nothing calls this directly

Calls 7

ShutdownMethod · 0.95
NewTLSEAutoEncryptConfigFunction · 0.85
FatalfMethod · 0.80
ValidateMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected