From 26e266a951e3d1397e86fa920c8373ac29684295 Mon Sep 17 00:00:00 2001 From: Pauline Middelink Date: Sun, 5 Mar 2017 17:50:11 +0100 Subject: [PATCH] Fix type of ID field in `cmd_snapshots` type Snapshot --- src/cmds/restic/cmd_snapshots.go | 4 ++-- src/cmds/restic/integration_test.go | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cmds/restic/cmd_snapshots.go b/src/cmds/restic/cmd_snapshots.go index 634cab0cf..5e3db0c5c 100644 --- a/src/cmds/restic/cmd_snapshots.go +++ b/src/cmds/restic/cmd_snapshots.go @@ -166,7 +166,7 @@ func printSnapshotsReadable(stdout io.Writer, list []*restic.Snapshot) { type Snapshot struct { *restic.Snapshot - ID string `json:"id"` + ID *restic.ID `json:"id"` } // printSnapshotsJSON writes the JSON representation of list to stdout. @@ -178,7 +178,7 @@ func printSnapshotsJSON(stdout io.Writer, list []*restic.Snapshot) error { k := Snapshot{ Snapshot: sn, - ID: sn.ID().String(), + ID: sn.ID(), } snapshots = append(snapshots, k) } diff --git a/src/cmds/restic/integration_test.go b/src/cmds/restic/integration_test.go index 6bb7ed254..a4ad49ba9 100644 --- a/src/cmds/restic/integration_test.go +++ b/src/cmds/restic/integration_test.go @@ -161,7 +161,7 @@ func testRunFind(t testing.TB, gopts GlobalOptions, pattern string) []string { return strings.Split(string(buf.Bytes()), "\n") } -func testRunSnapshots(t testing.TB, gopts GlobalOptions) (*Snapshot, map[string]Snapshot) { +func testRunSnapshots(t testing.TB, gopts GlobalOptions) (newest *Snapshot, snapmap map[restic.ID]Snapshot) { buf := bytes.NewBuffer(nil) globalOptions.stdout = buf globalOptions.JSON = true @@ -177,15 +177,14 @@ func testRunSnapshots(t testing.TB, gopts GlobalOptions) (*Snapshot, map[string] snapshots := []Snapshot{} OK(t, json.Unmarshal(buf.Bytes(), &snapshots)) - var newest *Snapshot - snapmap := make(map[string]Snapshot, len(snapshots)) + snapmap = make(map[restic.ID]Snapshot, len(snapshots)) for _, sn := range snapshots { - snapmap[sn.ID] = sn + snapmap[*sn.ID] = sn if newest == nil || sn.Time.After(newest.Time) { newest = &sn } } - return newest, snapmap + return } func testRunForget(t testing.TB, gopts GlobalOptions, args ...string) {