z_test.go 654 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package metla
  2. import (
  3. "bytes"
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. "os"
  8. "testing"
  9. )
  10. var contentPath = "test"
  11. func filePath(name string) string {
  12. return fmt.Sprintf("%v/%v", contentPath, name)
  13. }
  14. func modified(name string) (res int64) {
  15. if info, err := os.Stat(filePath(name)); err == nil {
  16. res = info.ModTime().Unix()
  17. }
  18. return
  19. }
  20. func content(name string) ([]byte, error) {
  21. return ioutil.ReadFile(filePath(name))
  22. }
  23. func TestParser(t *testing.T) {
  24. m := New(modified, content)
  25. log.Println(m)
  26. var b bytes.Buffer
  27. params := map[string]interface{}{
  28. "name": "Heya ))",
  29. }
  30. log.Println(m.Exec("index1.html", params, &b))
  31. log.Println(b.String())
  32. }