Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Conversation

mcuadros
Copy link
Contributor

  • 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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 {
Copy link
Contributor

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())
Copy link
Contributor

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?

Copy link
Contributor Author

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

@mcuadros mcuadros merged commit a430260 into src-d:master Oct 19, 2016
@mcuadros mcuadros deleted the fs-temp branch December 13, 2016 10:14
mcuadros added a commit that referenced this pull request Jan 31, 2017
* utils: fs generic TestSuite

* fs: fs.TempFile

* utils: fs small changes requested

* utils: fs, test fs.Create overwriting files
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants