@marcel91200 / caddy Mirror · read-only / commits / 2c91688f
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

fix testharness, dumps the current config, only if the config was successfully loaded (#3385)

Mark Sargent committed May 10, 2020 at 08:11 UTC 2c91688f39a80afc48e232e989f13aafbc782cf5
1 file changed +8 -4
caddytest/caddytest.go
+8 -4
@@ -55,8 +55,9 @@ var (
55
56 // Tester represents an instance of a test client.
57 type Tester struct {
58 - Client *http.Client
59 - t *testing.T
58 + Client *http.Client
59 + configLoaded bool
60 + t *testing.T
61 }
62
63 // NewTester will create a new testing client with an attached cookie jar
@@ -73,7 +74,8 @@ func NewTester(t *testing.T) *Tester {
74 Jar: jar,
75 Timeout: Default.TestRequestTimeout,
76 },
76 - t: t,
77 + configLoaded: false,
78 + t: t,
79 }
80 }
81
@@ -114,7 +116,8 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
116 }
117
118 tc.t.Cleanup(func() {
117 - if tc.t.Failed() {
119 + if tc.t.Failed() && tc.configLoaded {
120 +
121 res, err := http.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort))
122 if err != nil {
123 tc.t.Log("unable to read the current config")
@@ -164,6 +167,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
167 return configLoadError{Response: string(body)}
168 }
169
170 + tc.configLoaded = true
171 return nil
172 }
173