From c8557dc00bd93ce8ecf0bb724856a320e129c71b Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 4 Jan 2021 11:11:36 -0700 Subject: 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. --- caddytest/caddytest.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'caddytest/caddytest.go') 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) -- cgit v1.2.3