Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an example file #4

Open
github-actions bot opened this issue Apr 11, 2021 · 0 comments
Open

add an example file #4

github-actions bot opened this issue Apr 11, 2021 · 0 comments
Labels

Comments

@github-actions
Copy link

add an example file

// # TODO: add an example file

import (
	"io/fs"

	"github.com/stretchr/testify/mock"

	"github.com/parrogo/writefs"
)

// # TODO: add an example file

// FileWriter provides a struct based on testify/mock.Mock
// that implements the fs.Writer.
//
// The struct is used to test the writefs package itself,
// and could be generally used to test methods that
// expects a writefs.WriteFS instance, by providing a
// mocked FileWriter type that you can return from you mocked
// writefs.WriteFS objects.
type FileWriter struct {
	mock.Mock
}

var _ writefs.FileWriter = &FileWriter{}

// Close implements fs.Close
func (w *FileWriter) Close() error {
	args := w.Called()
	return args.Error(0)
}

// Write implements writefs.Write
func (w *FileWriter) Write(buf []byte) (int, error) {
	args := w.Called(buf)
	return args.Int(0), args.Error(1)

}

// Read implements fs.Read
func (w *FileWriter) Read(buf []byte) (int, error) {
	args := w.Called(buf)
	return args.Int(0), args.Error(1)
}

// Stat implements fs.File
func (w *FileWriter) Stat() (fs.FileInfo, error) {
	args := w.Called()
	res := args.Get(0)
	if res == nil {
		return nil, args.Error(1)
	}
	return res.(fs.FileInfo), args.Error(1)
}
ew file mode 100644
ndex 0000000..33b1910
++ b/mock/fixtures/dir1/dir2/file3.txt.template

48adb6fac8bf482a823a7541a6f6184eb4571b2f

@github-actions github-actions bot added the todo label Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants