diff: fix test failure and add remark on quiet to changelog
This commit is contained in:
parent
77c850148a
commit
5f34ad523f
2 changed files with 15 additions and 5 deletions
|
@ -1,8 +1,11 @@
|
||||||
Enhancement: Support JSON output for diff
|
Enhancement: Support JSON output and quiet mode for diff
|
||||||
|
|
||||||
We've added support for getting machine-readable output for snapshot diff, just pass the
|
We've added support for getting machine-readable output for snapshot diff, just pass the
|
||||||
flag `--json` for `restic diff` and restic will output a JSON-encoded diff stats and change
|
flag `--json` for `restic diff` and restic will output a JSON-encoded diff stats and change
|
||||||
list.
|
list.
|
||||||
|
|
||||||
|
Passing the `--quiet` flag to the `diff` command will only print the summary
|
||||||
|
and suppress the detailed output.
|
||||||
|
|
||||||
https://github.com/restic/restic/issues/2508
|
https://github.com/restic/restic/issues/2508
|
||||||
https://github.com/restic/restic/pull/3592
|
https://github.com/restic/restic/pull/3592
|
|
@ -2011,19 +2011,26 @@ func TestDiff(t *testing.T) {
|
||||||
testRunBackup(t, "", []string{datadir}, opts, env.gopts)
|
testRunBackup(t, "", []string{datadir}, opts, env.gopts)
|
||||||
_, secondSnapshotID := lastSnapshot(snapshots, loadSnapshotMap(t, env.gopts))
|
_, secondSnapshotID := lastSnapshot(snapshots, loadSnapshotMap(t, env.gopts))
|
||||||
|
|
||||||
|
// quiet suppresses the diff output except for the summary
|
||||||
|
env.gopts.Quiet = false
|
||||||
_, err := testRunDiffOutput(env.gopts, "", secondSnapshotID)
|
_, err := testRunDiffOutput(env.gopts, "", secondSnapshotID)
|
||||||
rtest.Assert(t, err != nil, "expected error on invalid snapshot id")
|
rtest.Assert(t, err != nil, "expected error on invalid snapshot id")
|
||||||
|
|
||||||
out, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
|
out, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
|
||||||
if err != nil {
|
rtest.OK(t, err)
|
||||||
t.Fatalf("expected no error from diff for test repository, got %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pattern := range diffOutputRegexPatterns {
|
for _, pattern := range diffOutputRegexPatterns {
|
||||||
r, err := regexp.Compile(pattern)
|
r, err := regexp.Compile(pattern)
|
||||||
rtest.Assert(t, err == nil, "failed to compile regexp %v", pattern)
|
rtest.Assert(t, err == nil, "failed to compile regexp %v", pattern)
|
||||||
rtest.Assert(t, r.MatchString(out), "expected pattern %v in output, got\n%v", pattern, out)
|
rtest.Assert(t, r.MatchString(out), "expected pattern %v in output, got\n%v", pattern, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check quiet output
|
||||||
|
env.gopts.Quiet = true
|
||||||
|
outQuiet, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
|
||||||
|
rtest.OK(t, err)
|
||||||
|
|
||||||
|
rtest.Assert(t, len(outQuiet) < len(out), "expected shorter output on quiet mode %v vs. %v", len(outQuiet), len(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
type writeToOnly struct {
|
type writeToOnly struct {
|
||||||
|
|
Loading…
Reference in a new issue