Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2d0d23927 |
@@ -172,9 +172,9 @@ func TestBannerSuppressedInArgs(t *testing.T) {
|
||||
|
||||
// hermeticConfig is a complete, valid config that needs no network and
|
||||
// no credentials: file:// storage is exempt from the S3 credential
|
||||
// checks. A test that lists the destination must create its directory
|
||||
// first, because listing a directory that does not exist is an error.
|
||||
// Chunk, blob and compression settings are filled in by config.Load.
|
||||
// checks, and FileStorer over a directory that does not exist lists
|
||||
// zero objects without erroring. Chunk, blob and compression settings
|
||||
// are filled in by config.Load.
|
||||
const hermeticConfig = `age_recipients:
|
||||
- age1278m9q7dp3chsh2dcy82qk27v047zywyvtxwnj4cvt0z65jw6a7q5dqhfj
|
||||
snapshots:
|
||||
@@ -196,25 +196,22 @@ hostname: test-host
|
||||
// `snapshot list` is the command chosen because it is the only --json
|
||||
// command that reaches its document without a populated destination
|
||||
// store: it reads the local index, streams `metadata/` (empty here),
|
||||
// and treats an empty destination directory as an empty list rather
|
||||
// than a failure.
|
||||
// and treats a barren destination as an empty list rather than a
|
||||
// failure.
|
||||
//
|
||||
// Not parallel: it replaces os.Args, os.Stdout and the xdg globals.
|
||||
func TestEntryJSONStdoutIsExactlyOneDocument(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
configPath := filepath.Join(dir, "config.yml")
|
||||
storeDir := filepath.Join(dir, "store")
|
||||
|
||||
contents := fmt.Sprintf(hermeticConfig,
|
||||
filepath.Join(dir, "source"),
|
||||
storeDir,
|
||||
filepath.Join(dir, "store"),
|
||||
filepath.Join(dir, "index.sqlite"))
|
||||
|
||||
require.NoError(t,
|
||||
os.WriteFile(configPath, []byte(contents), configFileMode))
|
||||
|
||||
require.NoError(t, os.Mkdir(storeDir, 0o750))
|
||||
|
||||
// The PID lock lives under xdg.DataHome, which xdg resolves at
|
||||
// package init; point it at the temp dir so the test neither
|
||||
// touches nor collides with the real one.
|
||||
|
||||
@@ -25,8 +25,9 @@ type FileStorer struct {
|
||||
// write. Write operations (Put/PutWithProgress) call MkdirAll for the
|
||||
// per-blob parent directory, which also covers basePath on first use.
|
||||
// Get and Stat report a key under a missing basePath as ErrNotFound.
|
||||
// List and ListStream fail on a missing basePath, because listing it as
|
||||
// an empty store would make `prune` drop every local snapshot record.
|
||||
// List and ListStream fail on a missing basePath: a missing or unmounted
|
||||
// destination cannot be listed, and listing it as an empty store would
|
||||
// make `prune` drop every local snapshot record.
|
||||
//
|
||||
// Uses the real OS filesystem by default; call SetFilesystem to
|
||||
// override for testing.
|
||||
|
||||
@@ -31,8 +31,8 @@ func TestFileStorer(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestFileStorerListMissingDestination checks that List and ListStream
|
||||
// fail when the destination directory does not exist, instead of
|
||||
// reporting an empty store.
|
||||
// fail when the destination directory does not exist, as on an unmounted
|
||||
// volume, instead of reporting an empty store.
|
||||
func TestFileStorerListMissingDestination(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user