diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go new file mode 100644 index 000000000..c4aa263a0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go @@ -0,0 +1,27 @@ +package test_helpers + +import ( + "io/ioutil" + "os" +) + +type TempFile struct { + *os.File +} + +func NewTempFile(content []byte) (*TempFile, error) { + f, err := ioutil.TempFile("", "graceful-test") + if err != nil { + return nil, err + } + + f.Write(content) + return &TempFile{f}, nil +} + +func (tf *TempFile) Unlink() { + if tf.File != nil { + os.Remove(tf.Name()) + tf.File = nil + } +} |