diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go index 05aa1e3f52f9..635c52e1be1a 100644 --- a/caddytest/caddytest.go +++ b/caddytest/caddytest.go @@ -133,6 +133,15 @@ func (tc *Tester) initServer(rawConfig string, configType string) error { _ = json.Indent(&out, body, "", " ") tc.t.Logf("----------- failed with config -----------\n%s", out.String()) } + tc.t.Log("deleting existing config in test cleanup") + deleteRequest, _ := http.NewRequest(http.MethodDelete, fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort), nil) + res, err := tc.Client.Do(deleteRequest) + if err != nil { + tc.t.Logf("failed to delete existing config: %s", err) + } + if res != nil { + _, _ = io.Copy(io.Discard, res.Body) + } }) rawConfig = prependCaddyFilePath(rawConfig)