in the pantry with your cupcakes

This commit is contained in:
Mark Bates 2019-09-01 17:41:03 -04:00
parent fb05947cac
commit 7779fbd3a9
3 changed files with 19 additions and 19 deletions

View File

@ -17,18 +17,18 @@ const mould = "/easy/listening/sugar.file"
const hart = "/easy/listening/grant.hart" const hart = "/easy/listening/grant.hart"
const husker = "github.com/husker/du" const husker = "github.com/husker/du"
type FileSystem struct { type Suite struct {
fs.FileSystem fs.FileSystem
} }
func NewFileSystem(yourfs fs.FileSystem) (*FileSystem, error) { func NewSuite(yourfs fs.FileSystem) (Suite, error) {
suite := &FileSystem{ suite := Suite{
FileSystem: yourfs, FileSystem: yourfs,
} }
return suite, nil return suite, nil
} }
func (s *FileSystem) Test(t *testing.T) { func (s Suite) Test(t *testing.T) {
rv := reflect.ValueOf(s) rv := reflect.ValueOf(s)
rt := rv.Type() rt := rv.Type()
if rt.NumMethod() == 0 { if rt.NumMethod() == 0 {
@ -43,7 +43,7 @@ func (s *FileSystem) Test(t *testing.T) {
} }
} }
func (s *FileSystem) 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.FileSystem, name)
t.Run(name, func(st *testing.T) { t.Run(name, func(st *testing.T) {
@ -68,7 +68,7 @@ func (s *FileSystem) sub(t *testing.T, m reflect.Method) {
}) })
} }
func (s *FileSystem) Clean() error { func (s Suite) Clean() error {
pt, err := s.Parse("/") pt, err := s.Parse("/")
if err != nil { if err != nil {
return err return err
@ -85,7 +85,7 @@ func (s *FileSystem) Clean() error {
return nil return nil
} }
func (s *FileSystem) Test_Create(t *testing.T) { func (s Suite) Test_Create(t *testing.T) {
r := require.New(t) r := require.New(t)
pt, err := s.Parse(mould) pt, err := s.Parse(mould)
@ -104,7 +104,7 @@ func (s *FileSystem) Test_Create(t *testing.T) {
r.NoError(s.RemoveAll(pt.String())) r.NoError(s.RemoveAll(pt.String()))
} }
func (s *FileSystem) Test_Current(t *testing.T) { func (s Suite) Test_Current(t *testing.T) {
r := require.New(t) r := require.New(t)
info, err := s.Current() info, err := s.Current()
@ -112,7 +112,7 @@ func (s *FileSystem) Test_Current(t *testing.T) {
r.NotZero(info) r.NotZero(info)
} }
func (s *FileSystem) Test_Info(t *testing.T) { func (s Suite) Test_Info(t *testing.T) {
r := require.New(t) r := require.New(t)
cur, err := s.Current() cur, err := s.Current()
@ -124,15 +124,15 @@ func (s *FileSystem) Test_Info(t *testing.T) {
} }
func (s *FileSystem) Test_MkdirAll(t *testing.T) { func (s Suite) Test_MkdirAll(t *testing.T) {
panic("not implemented") panic("not implemented")
} }
func (s *FileSystem) Test_Open(t *testing.T) { func (s Suite) Test_Open(t *testing.T) {
panic("not implemented") panic("not implemented")
} }
func (s *FileSystem) Test_Parse(t *testing.T) { func (s Suite) Test_Parse(t *testing.T) {
r := require.New(t) r := require.New(t)
cur, err := s.Current() cur, err := s.Current()
@ -165,11 +165,11 @@ func (s *FileSystem) Test_Parse(t *testing.T) {
} }
} }
func (s *FileSystem) Test_ReadFile(t *testing.T) { func (s Suite) Test_ReadFile(t *testing.T) {
panic("not implemented") panic("not implemented")
} }
func (s *FileSystem) Test_Stat_Error(t *testing.T) { func (s Suite) Test_Stat_Error(t *testing.T) {
r := require.New(t) r := require.New(t)
cur, err := s.Current() cur, err := s.Current()
@ -203,7 +203,7 @@ func (s *FileSystem) Test_Stat_Error(t *testing.T) {
} }
} }
func (s *FileSystem) Test_Stat_Dir(t *testing.T) { func (s Suite) Test_Stat_Dir(t *testing.T) {
r := require.New(t) r := require.New(t)
cur, err := s.Current() cur, err := s.Current()
@ -239,7 +239,7 @@ func (s *FileSystem) Test_Stat_Dir(t *testing.T) {
} }
} }
func (s *FileSystem) Test_Stat_File(t *testing.T) { func (s Suite) Test_Stat_File(t *testing.T) {
r := require.New(t) r := require.New(t)
cur, err := s.Current() cur, err := s.Current()
@ -278,6 +278,6 @@ func (s *FileSystem) Test_Stat_File(t *testing.T) {
} }
} }
func (s *FileSystem) Test_Walk(t *testing.T) { func (s Suite) Test_Walk(t *testing.T) {
panic("not implemented") panic("not implemented")
} }

View File

@ -17,7 +17,7 @@ func Test_FS(t *testing.T) {
myfs.current.Dir = filepath.Join(myfs.current.Dir, ".fstest") myfs.current.Dir = filepath.Join(myfs.current.Dir, ".fstest")
myfs.paths.Current = myfs.current myfs.paths.Current = myfs.current
suite, err := fstest.NewFileSystem(myfs) suite, err := fstest.NewSuite(myfs)
r.NoError(err) r.NoError(err)
suite.Test(t) suite.Test(t)

View File

@ -20,7 +20,7 @@ func Test_FS(t *testing.T) {
WithInfo(myfs, info) WithInfo(myfs, info)
suite, err := fstest.NewFileSystem(myfs) suite, err := fstest.NewSuite(myfs)
r.NoError(err) r.NoError(err)
suite.Test(t) suite.Test(t)