-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package bun | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
type FileSystem interface { | ||
// ReadDir reads the directory named by dirname and returns | ||
// a list of directory entries sorted by filename. | ||
// It's mocking the io/ioutil.ReadDir. | ||
ReadDir(string) ([]os.FileInfo, error) | ||
|
||
// Open opens the named file for reading. If successful, methods on | ||
// the returned file can be used for reading. | ||
// It's partially mocking the os.Open function. | ||
Open(string) (File, error) | ||
|
||
// Getwd returns a rooted path name corresponding to the | ||
// current directory. If the current directory can be | ||
// reached via multiple paths (due to symbolic links), | ||
// Getwd may return any one of them. | ||
// It's mocking os.Getwd. | ||
Getwd() (string, error) | ||
} | ||
|
||
type File interface { | ||
io.ReadCloser | ||
} | ||
|
||
// osFS implements FileSystem | ||
type OSFS struct { | ||
} | ||
|
||
func (osfs OSFS) ReadDir(dirname string) ([]os.FileInfo, error) { | ||
return ioutil.ReadDir(dirname) | ||
} | ||
func (osfs OSFS) Open(name string) (File, error) { | ||
file, err := os.Open(name) | ||
return File(file), err | ||
} | ||
func (osfs OSFS) Getwd() (string, error) { | ||
return os.Getwd() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package test | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/adyatlov/bun/fs" | ||
) | ||
|
||
type FileSystem struct { | ||
} | ||
|
||
func (fs *FileSystem) ReadDir(name string) ([]os.FileInfo, error) { | ||
return nil, nil | ||
} | ||
|
||
func (fs *FileSystem) Open(name string) (fs.File, error) { | ||
return nil, nil | ||
} |