diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2021-01-04 11:11:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 11:11:36 -0700 |
commit | c8557dc00bd93ce8ecf0bb724856a320e129c71b (patch) | |
tree | 0310586287637c9114228452c6620aa5a84c736a /caddytest | |
parent | 1b453dd4fbea2f3a54362fb4c2115bab85cad1b7 (diff) |
caddyfile: Introduce basic linting and fmt check (#3923)
* caddyfile: Introduce basic linting and fmt check
This will help encourage people to keep their Caddyfiles tidy.
* Remove unrelated tests
I am not sure that testing the output of warnings here is quite the
right idea; these tests are just for syntax and parsing success.
Diffstat (limited to 'caddytest')
-rw-r--r-- | caddytest/caddytest.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go index 5387da7..4076bd5 100644 --- a/caddytest/caddytest.go +++ b/caddytest/caddytest.go @@ -336,7 +336,6 @@ func CompareAdapt(t *testing.T, rawConfig string, adapterName string, expectedRe } options := make(map[string]interface{}) - options["pretty"] = "true" result, warnings, err := cfgAdapter.Adapt([]byte(rawConfig), options) if err != nil { @@ -344,6 +343,14 @@ func CompareAdapt(t *testing.T, rawConfig string, adapterName string, expectedRe return false } + // prettify results to keep tests human-manageable + var prettyBuf bytes.Buffer + err = json.Indent(&prettyBuf, result, "", "\t") + if err != nil { + return false + } + result = prettyBuf.Bytes() + if len(warnings) > 0 { for _, w := range warnings { t.Logf("warning: directive: %s : %s", w.Directive, w.Message) |