diff --git a/cmd/restic/cmd_snapshots_test.go b/cmd/restic/cmd_snapshots_test.go new file mode 100644 index 000000000..04af1a3c1 --- /dev/null +++ b/cmd/restic/cmd_snapshots_test.go @@ -0,0 +1,18 @@ +package main + +import ( + "strings" + "testing" + + rtest "github.com/restic/restic/internal/test" +) + +// Regression test for #2979: no snapshots should print as [], not null. +func TestEmptySnapshotGroupJSON(t *testing.T) { + for _, grouped := range []bool{false, true} { + var w strings.Builder + printSnapshotGroupJSON(&w, nil, grouped) + + rtest.Equals(t, "[]", strings.TrimSpace(w.String())) + } +}