Add tests for case insensitivity of keys and saving contexts

This commit is contained in:
Matthew Holt
2016-09-24 13:24:33 -06:00
parent 76d9d695be
commit 9077cce126
2 changed files with 56 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ type httpContext struct {
func (h *httpContext) saveConfig(key string, cfg *SiteConfig) {
h.siteConfigs = append(h.siteConfigs, cfg)
h.keysToSiteConfigs[strings.ToLower(key)] = cfg
h.keysToSiteConfigs[key] = cfg
}
// InspectServerBlocks make sure that everything checks out before
@@ -178,8 +178,9 @@ func GetConfig(c *caddy.Controller) *SiteConfig {
// we should only get here during tests because directive
// actions typically skip the server blocks where we make
// the configs
ctx.saveConfig(key, &SiteConfig{Root: Root, TLS: new(caddytls.Config)})
return GetConfig(c)
cfg := &SiteConfig{Root: Root, TLS: new(caddytls.Config)}
ctx.saveConfig(key, cfg)
return cfg
}
// shortCaddyfileLoader loads a Caddyfile if positional arguments are