diff options
| author | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 03:04:06 -0700 |
|---|---|---|
| committer | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 03:04:06 -0700 |
| commit | 7885d63f644bb49d8da1d8313d5f4870d586a9c1 (patch) | |
| tree | 66b0c5fce2181e8a130cdd22f6c43a6750d48111 | |
| parent | 5f66408c9e2b50756a15fd821fe397a4723da7b6 (diff) | |
util: Reorder functions
Variables are generally declared at the top of a file.
| -rw-r--r-- | util/errors.go | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/util/errors.go b/util/errors.go index f10569e..fada687 100644 --- a/util/errors.go +++ b/util/errors.go @@ -28,6 +28,26 @@ import ( "github.com/pkg/errors" ) +var ( + // ErrSkipIntegration indicates integration tests shouldn't be run. + ErrSkipIntegration = errors.New("skipping integration test") +) + +// 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. +var testEnvVarName = "TEST_FILESYSTEM_ROOT" + +// 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 "", ErrSkipIntegration + } + return path, nil +} + // ErrReader wraps an io.Reader, passing along calls to Read() until a read // fails. Then, the error is stored, and all subsequent calls to Read() do // nothing. This allows you to write code which has many subsequent reads and @@ -114,22 +134,3 @@ func NeverError(err error) { log.Panicf("NeverError() check failed: %v", err) } } - -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") -) - -// 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 "", ErrSkipIntegration - } - return path, nil -} |