From f678f7cb0447c6b56c895ede04d2f9d26560c9cb Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 24 Jul 2022 11:22:57 +0200 Subject: [PATCH] fuse: cleanup test --- internal/fuse/snapshots_dirstruct_test.go | 10 +++++----- internal/restic/snapshot.go | 5 ----- internal/restic/testing.go | 5 +++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/fuse/snapshots_dirstruct_test.go b/internal/fuse/snapshots_dirstruct_test.go index 5b0d88c1b..2e96d2093 100644 --- a/internal/fuse/snapshots_dirstruct_test.go +++ b/internal/fuse/snapshots_dirstruct_test.go @@ -15,7 +15,7 @@ func TestPathsFromSn(t *testing.T) { id1, _ := restic.ParseID("1234567812345678123456781234567812345678123456781234567812345678") time1, _ := time.Parse("2006-01-02T15:04:05", "2021-01-01T00:00:01") sn1 := &restic.Snapshot{Hostname: "host", Username: "user", Tags: []string{"tag1", "tag2"}, Time: time1} - sn1.SetID(id1) + restic.TestSetSnapshotID(t, sn1, id1) var p []string var s string @@ -67,22 +67,22 @@ func TestMakeDirs(t *testing.T) { id0, _ := restic.ParseID("0000000012345678123456781234567812345678123456781234567812345678") time0, _ := time.Parse("2006-01-02T15:04:05", "2020-12-31T00:00:01") sn0 := &restic.Snapshot{Hostname: "host", Username: "user", Tags: []string{"tag1", "tag2"}, Time: time0} - sn0.SetID(id0) + restic.TestSetSnapshotID(t, sn0, id0) id1, _ := restic.ParseID("1234567812345678123456781234567812345678123456781234567812345678") time1, _ := time.Parse("2006-01-02T15:04:05", "2021-01-01T00:00:01") sn1 := &restic.Snapshot{Hostname: "host", Username: "user", Tags: []string{"tag1", "tag2"}, Time: time1} - sn1.SetID(id1) + restic.TestSetSnapshotID(t, sn1, id1) id2, _ := restic.ParseID("8765432112345678123456781234567812345678123456781234567812345678") time2, _ := time.Parse("2006-01-02T15:04:05", "2021-01-01T01:02:03") sn2 := &restic.Snapshot{Hostname: "host2", Username: "user2", Tags: []string{"tag2", "tag3", "tag4"}, Time: time2} - sn2.SetID(id2) + restic.TestSetSnapshotID(t, sn2, id2) id3, _ := restic.ParseID("aaaaaaaa12345678123456781234567812345678123456781234567812345678") time3, _ := time.Parse("2006-01-02T15:04:05", "2021-01-01T01:02:03") sn3 := &restic.Snapshot{Hostname: "host", Username: "user2", Tags: []string{}, Time: time3} - sn3.SetID(id3) + restic.TestSetSnapshotID(t, sn3, id3) sds.makeDirs(restic.Snapshots{sn0, sn1, sn2, sn3}) diff --git a/internal/restic/snapshot.go b/internal/restic/snapshot.go index 2e8fa8a15..b12548459 100644 --- a/internal/restic/snapshot.go +++ b/internal/restic/snapshot.go @@ -146,11 +146,6 @@ func (sn Snapshot) ID() *ID { return sn.id } -// SetID sets the snapshot's ID. -func (sn *Snapshot) SetID(id ID) { - sn.id = &id -} - func (sn *Snapshot) fillUserInfo() error { usr, err := user.Current() if err != nil { diff --git a/internal/restic/testing.go b/internal/restic/testing.go index 79bc0813a..ebafdf651 100644 --- a/internal/restic/testing.go +++ b/internal/restic/testing.go @@ -207,3 +207,8 @@ func TestParseID(s string) ID { func TestParseHandle(s string, t BlobType) BlobHandle { return BlobHandle{ID: TestParseID(s), Type: t} } + +// TestSetSnapshotID sets the snapshot's ID. +func TestSetSnapshotID(t testing.TB, sn *Snapshot, id ID) { + sn.id = &id +}