diff file/file.go @ 15:9b4ec6b5c23e

Add tests for multipass files.
author Paul Fisher <paul@pfish.zone>
date Thu, 29 Oct 2015 23:56:53 -0400
parents da6c493cf08a
children 00d30c67b56d
line wrap: on
line diff
--- a/file/file.go	Thu Oct 29 21:31:28 2015 -0400
+++ b/file/file.go	Thu Oct 29 23:56:53 2015 -0400
@@ -23,8 +23,13 @@
 )
 
 var (
-	// Raised when
+	// Raised when there's an error in the file format.
 	ErrorBadFile = errors.New("multipass/file: Invalid file format")
+
+	// we spin waiting for the file to become available, doubling our wait time
+	// every time it's unavailable.  If the wait time is longer than this,
+	// give up.  Variable so it can be set in tests.
+	maxDelay = time.Minute
 )
 
 type ShadowFile struct {
@@ -176,7 +181,7 @@
 			if !ok {
 				return nil, err
 			}
-			if errno != syscall.EEXIST || delay > time.Minute {
+			if errno != syscall.EEXIST || delay > maxDelay {
 				return nil, err
 			}
 			time.Sleep(delay)