summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Sargent <99003+sarge@users.noreply.github.com>2020-05-10 08:11:35 +1200
committerGitHub <noreply@github.com>2020-05-10 08:11:35 +1200
commit2c91688f39a80afc48e232e989f13aafbc782cf5 (patch)
tree85bc60b06f58b172c1a6706a53609a20f01aaa3b
parent513e0240fd25ef51a8c2f9c87f2bc79d0fd9c91e (diff)
fix testharness, dumps the current config, only if the config was successfully loaded (#3385)
-rw-r--r--caddytest/caddytest.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go
index 48dd3fa..059b3e1 100644
--- a/caddytest/caddytest.go
+++ b/caddytest/caddytest.go
@@ -55,8 +55,9 @@ var (
// Tester represents an instance of a test client.
type Tester struct {
- Client *http.Client
- t *testing.T
+ Client *http.Client
+ configLoaded bool
+ t *testing.T
}
// NewTester will create a new testing client with an attached cookie jar
@@ -73,7 +74,8 @@ func NewTester(t *testing.T) *Tester {
Jar: jar,
Timeout: Default.TestRequestTimeout,
},
- t: t,
+ 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
}