Skip to content

add an example file #4

Description

@github-actions

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions