-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File fixture get first line #106
Conversation
Uses SAUCE_USERNAME and SAUCE_ACCESS_KEY vars in travis ci
…f non-reusable data (i.e. card numbers in a test environment) to use in your tests.
I don't understand where the old (july) commits come from.. they seem not to have affected any files? |
In the files changed I only see the changes to the 2 files you mention, so the rest is probably some Git branch magic affecting you. |
throw new IOException(fullName + " is an empty file."); | ||
} | ||
|
||
//Overwrite file, minus the first line. |
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.
Any chance you are willing to rewrite this to a (streaming) write to another file (e.g. .new) and at the end remove old file and rename new file to old name?
That way the entire file does not need to be loaded in memory and there is no chance of corrupting the existing file.
Maybe a bit overkill for the purpose at hand, but that just feels safer...
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.
See commit below. Added a utility method to do an incremental write from the scanner using a printwriter.
This method is used to create a temporary file. Temp file gets copied over the original file and gets deleted afterwards
Is that what you meant?
@@ -175,6 +175,28 @@ public static File writeFile(String filename, String content) { | |||
return new File(filename); | |||
} | |||
|
|||
public static File writeStreamFromScanner(String filename, Scanner sc){ |
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.
Looks good (exceptie for some spacing issues preceding '(')
Maybe rename method to writeFromScanner
, as there is no 'stream' involved?
Added takeFirstLineFrom file method. Allows for using a file based list of non-reusable data (i.e. card numbers in a test environment) to use in your tests. May be useful for others as well