diff options
| author | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 02:21:08 -0700 |
|---|---|---|
| committer | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 02:22:29 -0700 |
| commit | 0d4d11af2883bac66ecc427cdde37aa995b93ca8 (patch) | |
| tree | be426d602b210d91a3e0121ad4757dad8fef44cd /util/errors.go | |
| parent | 18925df4483ccf5c48dfb4314f85c1b37a1cbe81 (diff) | |
Random changesext4
Diffstat (limited to 'util/errors.go')
| -rw-r--r-- | util/errors.go | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/util/errors.go b/util/errors.go index f10569e..f0b9403 100644 --- a/util/errors.go +++ b/util/errors.go @@ -28,6 +28,28 @@ import ( "github.com/pkg/errors" ) +var ( + // ErrNotRoot indicates the action is restricted to the superuser. + ErrNotRoot = errors.New("only root can perform this action") + // 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 +136,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 -} |