mirror of https://github.com/markbates/pkger.git
three marlenas
This commit is contained in:
parent
7779fbd3a9
commit
85055a4cb7
2
fs/fs.go
2
fs/fs.go
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/markbates/pkger/here"
|
"github.com/markbates/pkger/here"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileSystem interface {
|
type Warehouse interface {
|
||||||
Parse(p string) (Path, error)
|
Parse(p string) (Path, error)
|
||||||
Abs(string) (string, error)
|
Abs(string) (string, error)
|
||||||
AbsPath(Path) (string, error)
|
AbsPath(Path) (string, error)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/markbates/pkger/fs"
|
"github.com/markbates/pkger/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Files(fx fs.FileSystem) (TestFiles, error) {
|
func Files(fx fs.Warehouse) (TestFiles, error) {
|
||||||
tf := TestFiles{}
|
tf := TestFiles{}
|
||||||
for _, f := range fileList {
|
for _, f := range fileList {
|
||||||
pt, err := fx.Parse(f)
|
pt, err := fx.Parse(f)
|
||||||
|
|
|
@ -18,12 +18,12 @@ const hart = "/easy/listening/grant.hart"
|
||||||
const husker = "github.com/husker/du"
|
const husker = "github.com/husker/du"
|
||||||
|
|
||||||
type Suite struct {
|
type Suite struct {
|
||||||
fs.FileSystem
|
fs.Warehouse
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSuite(yourfs fs.FileSystem) (Suite, error) {
|
func NewSuite(yourfs fs.Warehouse) (Suite, error) {
|
||||||
suite := Suite{
|
suite := Suite{
|
||||||
FileSystem: yourfs,
|
Warehouse: yourfs,
|
||||||
}
|
}
|
||||||
return suite, nil
|
return suite, nil
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func (s Suite) Test(t *testing.T) {
|
||||||
|
|
||||||
func (s Suite) sub(t *testing.T, m reflect.Method) {
|
func (s Suite) sub(t *testing.T, m reflect.Method) {
|
||||||
name := strings.TrimPrefix(m.Name, "Test_")
|
name := strings.TrimPrefix(m.Name, "Test_")
|
||||||
name = fmt.Sprintf("%T_%s", s.FileSystem, name)
|
name = fmt.Sprintf("%T_%s", s.Warehouse, name)
|
||||||
t.Run(name, func(st *testing.T) {
|
t.Run(name, func(st *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
|
|
|
@ -15,10 +15,10 @@ type File struct {
|
||||||
info *fs.FileInfo
|
info *fs.FileInfo
|
||||||
her here.Info
|
her here.Info
|
||||||
path fs.Path
|
path fs.Path
|
||||||
fs fs.FileSystem
|
fs fs.Warehouse
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFile(fx fs.FileSystem, osf *os.File) (*File, error) {
|
func NewFile(fx fs.Warehouse, osf *os.File) (*File, error) {
|
||||||
|
|
||||||
pt, err := fx.Parse(osf.Name())
|
pt, err := fx.Parse(osf.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/markbates/pkger/internal/maps"
|
"github.com/markbates/pkger/internal/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ fs.FileSystem = &FS{}
|
var _ fs.Warehouse = &FS{}
|
||||||
|
|
||||||
type FS struct {
|
type FS struct {
|
||||||
infos *maps.Infos
|
infos *maps.Infos
|
||||||
|
|
|
@ -27,7 +27,7 @@ type File struct {
|
||||||
parent fs.Path
|
parent fs.Path
|
||||||
writer *bytes.Buffer
|
writer *bytes.Buffer
|
||||||
reader io.Reader
|
reader io.Reader
|
||||||
fs fs.FileSystem
|
fs fs.Warehouse
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) Seek(offset int64, whence int) (int64, error) {
|
func (f *File) Seek(offset int64, whence int) (int64, error) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/markbates/pkger/internal/maps"
|
"github.com/markbates/pkger/internal/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ fs.FileSystem = &FS{}
|
var _ fs.Warehouse = &FS{}
|
||||||
|
|
||||||
func WithInfo(fx *FS, infos ...here.Info) {
|
func WithInfo(fx *FS, infos ...here.Info) {
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
|
|
Loading…
Reference in New Issue