コード例 #1
0
func TestSearchTemplates(t *testing.T) {
	root := filepath.Join(filepath.Dir(os.Args[0]), ".test1")
	templates := []string{"abc", "xyz"}

	prepareTestDirectoryWithLanguage(root, templates)

	l := template.SearchTemplates(root, false)

	for _, n := range templates {
		temp := l[n]
		if temp == nil {
			t.Fatalf("templateGroup[%s] not found", n)
		}
		if len(temp.Templates) != 2 {
			t.Fatalf("templateGroup[%s] don't have 2 templates", n)
		}
		trsms := temp.Find(template.TemplateSms, "tr")
		if trsms == nil {
			t.Fatal("TR Sms template is nil")
		}
		ensms := temp.Find(template.TemplateSms, "en")
		if ensms == nil {
			t.Fatal("EN Sms template is nil")
		}
	}
	os.Remove(root)
}
コード例 #2
0
func TestSearchTemplatesWithoutLanguage(t *testing.T) {
	root := filepath.Join(filepath.Dir(os.Args[0]), ".test2")
	templates := []string{"asd", "fgh"}
	prepareTestDirectoryWithoutLanguage(root, templates)

	l := template.SearchTemplates(root, false)

	for _, n := range templates {
		temp := l[n]
		if temp == nil {
			t.Fatalf("templateGroup[%s] not found", n)
		}
		if len(temp.Templates) != 2 {
			t.Fatalf("templateGroup[%s] don't have 2 templates", n)
		}

		sms := temp.Find(template.TemplateSms, template.TemplateLanguageNone)
		if sms == nil {
			t.Fatal("Sms template is nil")
		}
		push := temp.Find(template.TemplatePush, template.TemplateLanguageNone)
		if push == nil {
			t.Fatal("Push template is nil")
		}
	}
	os.Remove(root)
}
コード例 #3
0
func (server *Server) LoadTemplates() {
	server.templates = template.SearchTemplates(server.Config.TemplatePath, server.Config.CacheAtStart)
	for _, t := range server.templates {
		log.Debugf("server.go: TemplateGroup[%s] founded", t.Name)
	}
}