From 6bee0aafc2ad15c9d333a6459e1215be25f1aef3 Mon Sep 17 00:00:00 2001 From: greatroar <@> Date: Mon, 5 Oct 2020 15:04:20 +0200 Subject: [PATCH] Regression test for #2979 --- cmd/restic/cmd_snapshots_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cmd/restic/cmd_snapshots_test.go 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())) + } +}