func contentRoot() gopath.GoPath { if wd, err := os.Getwd(); err == nil { return gopath.FromPath(wd) } else { panic(err) } }
func TestExportTemplates(t *testing.T) { var wd, _ = os.Getwd() var sut = NewStaticLoader() var targetPath = gopath.FromPath(wd).JoinPath("gone_test") defer os.RemoveAll(targetPath.Path()) var err = sut.WriteAllTemplates(targetPath) if err != nil { t.Fatalf("Couldn't write templates: %v", err) } }
func templatePath(contentRoot gopath.GoPath, cfg config.Config) (result gopath.GoPath) { // configuration result = gopath.FromPath(cfg.TemplatePath) if !result.IsEmpty() { if !result.IsDirectory() { log.Fatalf("configured template path is no directory: %s", result.Path()) } log.Printf("using templates from %s (by configuration)", result.Path()) return result } // convention result = contentRoot.JoinPath(defaultTemplateDirectoryName) if result.IsDirectory() { log.Printf("using templates from %s (by convention)", result.Path()) return result } // default log.Printf("using default templates") return gopath.Empty() }
func getwdPath(t *testing.T) gopath.GoPath { return gopath.FromPath(getwd(t)) }