diff options
Diffstat (limited to '')
-rw-r--r-- | middleware/chaos/setup.go | 8 | ||||
-rw-r--r-- | middleware/chaos/setup_test.go | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/middleware/chaos/setup.go b/middleware/chaos/setup.go index 816dc7944..17b4f90cc 100644 --- a/middleware/chaos/setup.go +++ b/middleware/chaos/setup.go @@ -12,6 +12,7 @@ func init() { ServerType: "dns", Action: setup, }) + } func setup(c *caddy.Controller) error { @@ -28,13 +29,16 @@ func setup(c *caddy.Controller) error { } func chaosParse(c *caddy.Controller) (string, map[string]bool, error) { + // Set here so we pick up AppName and AppVersion that get set in coremain's init(). + chaosVersion = caddy.AppName + "-" + caddy.AppVersion + version := "" authors := make(map[string]bool) for c.Next() { args := c.RemainingArgs() if len(args) == 0 { - return defaultVersion, nil, nil + return chaosVersion, nil, nil } if len(args) == 1 { return args[0], nil, nil @@ -48,4 +52,4 @@ func chaosParse(c *caddy.Controller) (string, map[string]bool, error) { return version, authors, nil } -var defaultVersion = caddy.AppName + "-" + caddy.AppVersion +var chaosVersion string diff --git a/middleware/chaos/setup_test.go b/middleware/chaos/setup_test.go index c1741cdf6..6f3c13fb3 100644 --- a/middleware/chaos/setup_test.go +++ b/middleware/chaos/setup_test.go @@ -1,7 +1,6 @@ package chaos import ( - "fmt" "strings" "testing" @@ -18,19 +17,11 @@ func TestSetupChaos(t *testing.T) { }{ // positive { - `chaos`, false, defaultVersion, "", "", - }, - { `chaos v2`, false, "v2", "", "", }, { `chaos v3 "Miek Gieben"`, false, "v3", "Miek Gieben", "", }, - { - fmt.Sprintf(`chaos { - %s - }`, defaultVersion), false, defaultVersion, "", "", - }, } for i, test := range tests { |