Documentation ¶
Overview ¶
Package filewalktestutil provides utilities for testing code that uses filewalk.FS.
Index ¶
- func Scan(ctx context.Context, fs filewalk.FS, prefix string) ([]filewalk.Entry, error)
- func ScanNames(ctx context.Context, fs filewalk.FS, prefix string) ([]string, error)
- func WalkContents(ctx context.Context, fs filewalk.FS, roots ...string) (prefixes, names []string, err error)
- type MockFS
- func (m *MockFS) Base(pathname string) string
- func (m *MockFS) IsNotExist(err error) bool
- func (m *MockFS) IsPermissionError(err error) bool
- func (m *MockFS) Join(components ...string) string
- func (m *MockFS) LevelScanner(pathname string) filewalk.LevelScanner
- func (m *MockFS) Lstat(ctx context.Context, path string) (file.Info, error)
- func (m *MockFS) Open(pathname string) (fs.File, error)
- func (m *MockFS) OpenCtx(_ context.Context, pathname string) (fs.File, error)
- func (m *MockFS) Readlink(_ context.Context, _ string) (string, error)
- func (m *MockFS) Scheme() string
- func (m *MockFS) Stat(_ context.Context, pathname string) (file.Info, error)
- func (m *MockFS) String() string
- func (m *MockFS) SysXAttr(_ any, merge file.XAttr) any
- func (m *MockFS) XAttr(_ context.Context, pathname string, fi file.Info) (file.XAttr, error)
- type Option
- type Walker
- func (w *Walker) Contents(ctx context.Context, _ *struct{}, prefix string, contents []filewalk.Entry) (file.InfoList, error)
- func (w *Walker) Done(_ context.Context, _ *struct{}, _ string, err error) error
- func (w *Walker) Prefix(_ context.Context, _ *struct{}, prefix string, _ file.Info, _ error) (bool, file.InfoList, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MockFS ¶
type MockFS struct {
// contains filtered or unexported fields
}
MockFS implements filewalk.FS for testing purposes. Note that:
- It does not support soft links.
- It does not support Open on directories, instead, LevelScanner should be used.
- It only supports paths that begin with the root directory passed to NewMockFS.
func (*MockFS) IsNotExist ¶
func (*MockFS) IsPermissionError ¶
func (*MockFS) LevelScanner ¶
func (m *MockFS) LevelScanner(pathname string) filewalk.LevelScanner
type Option ¶
type Option func(o *options)
func WithYAMLConfig ¶
WithYAMLConfig specifies the YAML config to use for creating a mock filesystem.
Click to show internal directories.
Click to hide internal directories.