(t *testing.T)
| 586 | } |
| 587 | |
| 588 | func TestBaseDirectory(t *testing.T) { |
| 589 | mustStr := "Hello from template_tests/base_dir_test/" |
| 590 | |
| 591 | fs := pongo2.MustNewLocalFileSystemLoader("") |
| 592 | s := pongo2.NewSet("test set with base directory", fs) |
| 593 | s.Globals["base_directory"] = "template_tests/base_dir_test/" |
| 594 | if err := fs.SetBaseDir(s.Globals["base_directory"].(string)); err != nil { |
| 595 | t.Fatal(err) |
| 596 | } |
| 597 | |
| 598 | matches, err := filepath.Glob("./template_tests/base_dir_test/subdir/*") |
| 599 | if err != nil { |
| 600 | t.Fatal(err) |
| 601 | } |
| 602 | for _, match := range matches { |
| 603 | match = strings.Replace(match, fmt.Sprintf("template_tests%cbase_dir_test%c", filepath.Separator, filepath.Separator), "", -1) |
| 604 | |
| 605 | tpl, err := s.FromFile(match) |
| 606 | if err != nil { |
| 607 | t.Fatal(err) |
| 608 | } |
| 609 | out, err := tpl.Execute(nil) |
| 610 | if err != nil { |
| 611 | t.Fatal(err) |
| 612 | } |
| 613 | if out != mustStr { |
| 614 | t.Errorf("%s: out ('%s') != mustStr ('%s')", match, out, mustStr) |
| 615 | } |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | func BenchmarkCache(b *testing.B) { |
| 620 | cacheSet := pongo2.NewSet("cache set", pongo2.MustNewLocalFileSystemLoader("")) |
nothing calls this directly
no test coverage detected
searching dependent graphs…