mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
fix testharness, dumps the current config, only if the config was successfully loaded (#3385)
This commit is contained in:
parent
513e0240fd
commit
2c91688f39
1 changed files with 8 additions and 4 deletions
|
@ -56,6 +56,7 @@ var (
|
|||
// Tester represents an instance of a test client.
|
||||
type Tester struct {
|
||||
Client *http.Client
|
||||
configLoaded bool
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
|
@ -73,6 +74,7 @@ func NewTester(t *testing.T) *Tester {
|
|||
Jar: jar,
|
||||
Timeout: Default.TestRequestTimeout,
|
||||
},
|
||||
configLoaded: false,
|
||||
t: t,
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +116,8 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
|
|||
}
|
||||
|
||||
tc.t.Cleanup(func() {
|
||||
if tc.t.Failed() {
|
||||
if tc.t.Failed() && tc.configLoaded {
|
||||
|
||||
res, err := http.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort))
|
||||
if err != nil {
|
||||
tc.t.Log("unable to read the current config")
|
||||
|
@ -164,6 +167,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
|
|||
return configLoadError{Response: string(body)}
|
||||
}
|
||||
|
||||
tc.configLoaded = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue