From e3e3a8a6955651d034ffd528ffb41c942b8db46b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 2 Apr 2017 19:56:33 +0200 Subject: [PATCH] local: Add layout tests --- src/restic/backend/local/local_layout_test.go | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/restic/backend/local/local_layout_test.go diff --git a/src/restic/backend/local/local_layout_test.go b/src/restic/backend/local/local_layout_test.go new file mode 100644 index 000000000..278eac4ba --- /dev/null +++ b/src/restic/backend/local/local_layout_test.go @@ -0,0 +1,43 @@ +package local + +import ( + "path/filepath" + . "restic/test" + "testing" +) + +func TestLocalLayout(t *testing.T) { + path, cleanup := TempDir(t) + defer cleanup() + + var tests = []struct { + filename string + layout string + failureExpected bool + }{ + {"repo-layout-local.tar.gz", "", false}, + {"repo-layout-cloud.tar.gz", "", false}, + {"repo-layout-s3-old.tar.gz", "", false}, + } + + for _, test := range tests { + t.Run(test.filename, func(t *testing.T) { + SetupTarTestFixture(t, path, filepath.Join("..", "testdata", test.filename)) + + repo := filepath.Join(path, "repo") + be, err := Open(Config{ + Path: repo, + Layout: test.layout, + }) + if err != nil { + t.Fatal(err) + } + + if be == nil { + t.Fatalf("Open() returned nil but no error") + } + + RemoveAll(t, filepath.Join(path, "repo")) + }) + } +}