diff options
| author | Joe Richey joerichey@google.com <joerichey@google.com> | 2017-05-23 18:38:38 -0700 |
|---|---|---|
| committer | Joe Richey joerichey@google.com <joerichey@google.com> | 2017-05-31 12:35:28 -0700 |
| commit | 44c2c7aeda3de09a405ed06aadacbc2c0c7f2a67 (patch) | |
| tree | 74bd0fccf5c23a739b434893e1d02c16e0153fca /metadata/policy_test.go | |
| parent | 4b6d0ce14b8553a93b2d14fd858dfd35bfd61104 (diff) | |
metadata: reorganize and add consistency checks
This commit adds in IsValid() checks for the metadata structures that
let us enforce stronger invariants than those imposed by the protobuf
package. The main uses of this will be to check that metadata is valid
before writing it to the filesystem, and to check that the filesystem
contains valid metadata before returning it to the user. These functions
also will log the exact reason if the validity checks fail.
To have these checks in the metadata package, all of the various
constants have been moved to a single metadata/constants.go file. The
uses of these constants were changed accordingly.
Finally, this commit standardizes our use of errors so that they always
begin with an appropriate prefix.
Change-Id: I99008e2ee803ebe5f6236eb8d83fc83efcd22718
Diffstat (limited to 'metadata/policy_test.go')
| -rw-r--r-- | metadata/policy_test.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/metadata/policy_test.go b/metadata/policy_test.go index 593f3da..6dc2567 100644 --- a/metadata/policy_test.go +++ b/metadata/policy_test.go @@ -34,12 +34,13 @@ var goodPolicy = &PolicyData{ Options: DefaultOptions, } -// Creates a temporary directory in BASE_TEST_DIR for testing. Fails if the -// base directory is not specified. +// Creates a temporary directory in TEST_FILESYSTEM_ROOT for testing. Fails if +// the root directory is not specified. func createTestDirectory() (directory string, err error) { - baseDirectory := os.Getenv("BASE_TEST_DIR") + baseDirectory := os.Getenv("TEST_FILESYSTEM_ROOT") if s, err := os.Stat(baseDirectory); err != nil || !s.IsDir() { - return "", fmt.Errorf("invalid directory %q. Set BASE_TEST_DIR to be a valid directory", baseDirectory) + return "", fmt.Errorf("invalid directory %q: "+ + "set TEST_FILESYSTEM_ROOT to be a valid directory", baseDirectory) } directoryPath := filepath.Join(baseDirectory, "test") |