aboutsummaryrefslogtreecommitdiff
path: root/util/errors.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey@google.com>2017-07-18 21:51:15 -0700
committerGitHub <noreply@github.com>2017-07-18 21:51:15 -0700
commit8f4830c7715e5719780f195ce3400b8768c30688 (patch)
tree2db0016cc45fb35ab027a7dd95c8050a05605143 /util/errors.go
parent8867856db45abaed8b9e2539ee7c34d99360db56 (diff)
parentcc2de52228d89b2fbc53bc0e710aae699434d6da (diff)
Merge pull request #23 from google/fix
travis CI: Test config file
Diffstat (limited to 'util/errors.go')
-rw-r--r--util/errors.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/util/errors.go b/util/errors.go
index 2a865a3..f10569e 100644
--- a/util/errors.go
+++ b/util/errors.go
@@ -24,6 +24,8 @@ import (
"io"
"log"
"os"
+
+ "github.com/pkg/errors"
)
// ErrReader wraps an io.Reader, passing along calls to Read() until a read
@@ -113,17 +115,21 @@ func NeverError(err error) {
}
}
-// TestEnvVarName is the name on an environment variable that should be set to
-// an empty mountpoint. This is only used for integration tests.
-var TestEnvVarName = "TEST_FILESYSTEM_ROOT"
+var (
+ // testEnvVarName is the name on an environment variable that should be
+ // set to an empty mountpoint. This is only used for integration tests.
+ // If not set, integration tests are skipped.
+ testEnvVarName = "TEST_FILESYSTEM_ROOT"
+ // ErrSkipIntegration indicates integration tests shouldn't be run.
+ ErrSkipIntegration = errors.New("skipping integration test")
+)
-// TestPath returns a the path specified by TestEnvVarName. The function
-// panics if the environment variable is not set. This function is only used for
-// integration tests.
-func TestPath() (string, error) {
- path := os.Getenv(TestEnvVarName)
+// TestRoot returns a the root of a filesystem specified by testEnvVarName. This
+// function is only used for integration tests.
+func TestRoot() (string, error) {
+ path := os.Getenv(testEnvVarName)
if path == "" {
- return "", fmt.Errorf("%s: environment variable not set", TestEnvVarName)
+ return "", ErrSkipIntegration
}
return path, nil
}