github.com/Kindred87/Obsidian@v0.0.0-20210809203756-86936424b848/retrieval/html/helpers_test.go (about) 1 package html 2 3 import ( 4 "os" 5 6 "github.com/Kindred87/Obsidian/datasource" 7 "github.com/Kindred87/Obsidian/filetypes" 8 ) 9 10 // makeHTMLSpec creates and stores an HTML datasource specification. The datasource 11 // is expected to exist within the html/testdata directory. 12 func makeHTMLSpec(alias, filename string) error { 13 wd, err := os.Getwd() 14 if err != nil { 15 return err 16 } 17 18 spec := datasource.Specification{} 19 spec.SetAlias(alias) 20 spec.SetIncludeProgramDirectory(false) 21 spec.SetPaths([]string{wd + "\\testdata"}) 22 spec.SetFileType(filetypes.HTML.String()) 23 spec.SetFilenameSpecs([]datasource.FilenameSpec{{Filename: filename, NameIsSubstring: false}}) 24 spec.SetValueSpecs([]datasource.ValueSpec{{}}) 25 26 err = datasource.Add(&spec, true) 27 if err != nil { 28 return err 29 } 30 31 return nil 32 }