github.com/fredbi/git-chglog@v0.0.0-20190706071416-d35c598eac81/cmd/git-chglog/fs_mock.go (about) 1 package main 2 3 type mockFileSystem struct { 4 ReturnExists func(string) bool 5 ReturnMkdirP func(string) error 6 ReturnCreate func(string) (File, error) 7 ReturnWriteFile func(string, []byte) error 8 } 9 10 func (m *mockFileSystem) Exists(path string) bool { 11 return m.ReturnExists(path) 12 } 13 14 func (m *mockFileSystem) MkdirP(path string) error { 15 return m.ReturnMkdirP(path) 16 } 17 18 func (m *mockFileSystem) Create(name string) (File, error) { 19 return m.ReturnCreate(name) 20 } 21 22 func (m *mockFileSystem) WriteFile(path string, content []byte) error { 23 return m.ReturnWriteFile(path, content) 24 } 25 26 type mockFile struct { 27 File 28 ReturnWrite func([]byte) (int, error) 29 } 30 31 func (m *mockFile) Write(b []byte) (int, error) { 32 return m.ReturnWrite(b) 33 }