-
Notifications
You must be signed in to change notification settings - Fork 534
utils: fs.TempFile #88
Conversation
mcuadros
commented
Oct 18, 2016
- New fs.TempFile method in the fs.Filesystem interface, this abstraction is required to filesystem where the creation of a temporal file should be explicit
- utils.fs: new TestSuite for test any fs.Filesystem implementation
fs Filesystem | ||
} | ||
|
||
func (s *FilesystemSuite) TestCreate(c *C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create should truncate files if they already exists, I don't think that behavior is being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
utils/fs/os.go
Outdated
type OS struct { | ||
RootDir string | ||
base string | ||
tempfiles []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unused?
The name should be tempFiles.
utils/fs/os.go
Outdated
|
||
func (fs *OS) TempFile(dir, prefix string) (File, error) { | ||
fullpath := fs.Join(fs.base, dir) | ||
if err := fs.createDir(fullpath + "/"); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "/" portable? should be os.PathSeparator?
} | ||
|
||
fr, err := fs.Open(tmp) | ||
fr, err := fs.Open(fw.Filename()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TempFile already returns a File, do we really need to open it again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, as I explained in RealWorld
* utils: fs generic TestSuite * fs: fs.TempFile * utils: fs small changes requested * utils: fs, test fs.Create overwriting files