1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 18:17:03 +00:00

Logging and unit test changes

Logging methods were renamed so they don't trigger go-vet warnings for
error() and Error() formatting.

Unit tests were updated to use new github.com/stretchr repo (was renamed
from stretchrcom)

Missing methods were added to Message mock object.
This commit is contained in:
James Hillyerd
2013-09-13 14:06:57 -07:00
parent f50061ac82
commit 2e78e4e6f7
16 changed files with 180 additions and 171 deletions

View File

@@ -20,7 +20,7 @@ var cachedPartials = map[string]*template.Template{}
func RenderTemplate(name string, w http.ResponseWriter, data interface{}) error {
t, err := ParseTemplate(name, false)
if err != nil {
log.Error("Error in template '%v': %v", name, err)
log.LogError("Error in template '%v': %v", name, err)
return err
}
w.Header().Set("Expires", "-1")
@@ -32,7 +32,7 @@ func RenderTemplate(name string, w http.ResponseWriter, data interface{}) error
func RenderPartial(name string, w http.ResponseWriter, data interface{}) error {
t, err := ParseTemplate(name, true)
if err != nil {
log.Error("Error in template '%v': %v", name, err)
log.LogError("Error in template '%v': %v", name, err)
return err
}
w.Header().Set("Expires", "-1")
@@ -52,7 +52,7 @@ func ParseTemplate(name string, partial bool) (*template.Template, error) {
cfg := config.GetWebConfig()
tempPath := strings.Replace(name, "/", string(filepath.Separator), -1)
tempFile := filepath.Join(cfg.TemplateDir, tempPath)
log.Trace("Parsing template %v", tempFile)
log.LogTrace("Parsing template %v", tempFile)
var err error
var t *template.Template
@@ -72,10 +72,10 @@ func ParseTemplate(name string, partial bool) (*template.Template, error) {
// Allows us to disable caching for theme development
if cfg.TemplateCache {
if partial {
log.Trace("Caching partial %v", name)
log.LogTrace("Caching partial %v", name)
cachedTemplates[name] = t
} else {
log.Trace("Caching template %v", name)
log.LogTrace("Caching template %v", name)
cachedTemplates[name] = t
}
}