Refactor template tests to improve readability and consistency
- Cleaned up whitespace in debug, load, and walk test files for better formatting. - Enhanced logging statements for clarity during template loading and walking tests. - Standardized test structure to improve maintainability and readability across template-related tests.
This commit is contained in:
parent
ec8b6c336b
commit
bd463b0ec5
3 changed files with 12 additions and 12 deletions
|
|
@ -16,7 +16,7 @@ func TestDebugTemplateLoading(t *testing.T) {
|
|||
|
||||
// Test direct template loading
|
||||
t.Log("Testing direct template loading...")
|
||||
|
||||
|
||||
// Try to load a specific template file using application.App
|
||||
content, err := application.App.Read("messengers/templates/en/invite_member.mail.html")
|
||||
if err != nil {
|
||||
|
|
@ -25,7 +25,7 @@ func TestDebugTemplateLoading(t *testing.T) {
|
|||
t.Logf("Template file content length: %d", len(content))
|
||||
t.Logf("First 200 chars: %s", content[:min(200, len(content))])
|
||||
}
|
||||
|
||||
|
||||
// Test template parsing
|
||||
subject, body, html, err := parseTemplateContent(string(content), types.TemplateTypeMail)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,18 +16,18 @@ func TestLoadTemplate(t *testing.T) {
|
|||
// Test loading a specific template
|
||||
file := "messengers/templates/en/invite_member.mail.html"
|
||||
templateID := share.ID("messengers/templates", file)
|
||||
|
||||
|
||||
t.Logf("Testing loadTemplate with file: %s, templateID: %s", file, templateID)
|
||||
|
||||
|
||||
template, err := loadTemplate(file, templateID)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load template: %v", err)
|
||||
}
|
||||
|
||||
|
||||
if template == nil {
|
||||
t.Fatal("Template is nil")
|
||||
}
|
||||
|
||||
|
||||
t.Logf("Loaded template: ID=%s, Type=%s, Language=%s", template.ID, template.Type, template.Language)
|
||||
t.Logf("Subject: %s", template.Subject)
|
||||
t.Logf("Body length: %d", len(template.Body))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestWalkTemplates(t *testing.T) {
|
|||
|
||||
// Test Walk function directly
|
||||
t.Log("Testing Walk function directly...")
|
||||
|
||||
|
||||
// Check if templates directory exists
|
||||
exists, err := application.App.Exists("messengers/templates")
|
||||
if err != nil {
|
||||
|
|
@ -25,13 +25,13 @@ func TestWalkTemplates(t *testing.T) {
|
|||
t.Log("Templates directory not found")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
t.Log("Templates directory exists")
|
||||
|
||||
|
||||
// Test Walk with different extensions
|
||||
exts := []string{"*.mail.html", "*.sms.txt", "*.whatsapp.html"}
|
||||
t.Logf("Testing Walk with extensions: %v", exts)
|
||||
|
||||
|
||||
fileCount := 0
|
||||
err = application.App.Walk("messengers/templates", func(root, file string, isdir bool) error {
|
||||
t.Logf("Walk callback: root=%s, file=%s, isdir=%v", root, file, isdir)
|
||||
|
|
@ -40,10 +40,10 @@ func TestWalkTemplates(t *testing.T) {
|
|||
}
|
||||
return nil
|
||||
}, exts...)
|
||||
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Walk failed: %v", err)
|
||||
}
|
||||
|
||||
|
||||
t.Logf("Walk completed, found %d files", fileCount)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue