mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-29 15:15:51 +08:00
caddytest: normalize the JSON config (#6316)
* caddytest: normalize the JSON config
This commit is contained in:

committed by
GitHub

parent
fb63e2e40c
commit
4c90f1427f
@ -136,6 +136,20 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
|
||||
})
|
||||
|
||||
rawConfig = prependCaddyFilePath(rawConfig)
|
||||
// normalize JSON config
|
||||
if configType == "json" {
|
||||
tc.t.Logf("Before: %s", rawConfig)
|
||||
var conf any
|
||||
if err := json.Unmarshal([]byte(rawConfig), &conf); err != nil {
|
||||
return err
|
||||
}
|
||||
c, err := json.Marshal(conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rawConfig = string(c)
|
||||
tc.t.Logf("After: %s", rawConfig)
|
||||
}
|
||||
client := &http.Client{
|
||||
Timeout: Default.LoadRequestTimeout,
|
||||
}
|
||||
|
Reference in New Issue
Block a user