(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func 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 | } |
nothing calls this directly
no test coverage detected