aboutsummaryrefslogtreecommitdiff
path: root/util/errors.go
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-07-18 21:08:02 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-07-18 21:08:02 -0700
commit3afdd84a5c0cea217043e9d32ce61e9f6bccf18b (patch)
tree9503e9bb95db4938dababa0bfe2819d7cd7d7e56 /util/errors.go
parentf898a826ab24e03019323ade6a8785e2bf463a41 (diff)
tests: Unit tests and Integration tests work
Now the testing functions will skip the integration tests if a testing filesystem is not specified.
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
}