From e7d29c12273c86ebe7812c59346d079b8fea279d Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Tue, 19 Mar 2024 00:15:59 -0700 Subject: [PATCH] chore: fix tests --- internal/orchestrator/repo_test.go | 4 +- pkg/restic/restic_test.go | 67 +++++------------------------- 2 files changed, 13 insertions(+), 58 deletions(-) diff --git a/internal/orchestrator/repo_test.go b/internal/orchestrator/repo_test.go index a2e1ee6d..0dace95f 100644 --- a/internal/orchestrator/repo_test.go +++ b/internal/orchestrator/repo_test.go @@ -30,7 +30,7 @@ func TestBackup(t *testing.T) { Paths: []string{testData}, } - orchestrator, err := newRepoOrchestrator(r, helpers.ResticBinary(t)) + orchestrator, err := NewRepoOrchestrator(r, helpers.ResticBinary(t)) if err != nil { t.Fatalf("failed to create repo orchestrator: %v", err) } @@ -76,7 +76,7 @@ func TestSnapshotParenting(t *testing.T) { }, } - orchestrator, err := newRepoOrchestrator(r, helpers.ResticBinary(t)) + orchestrator, err := NewRepoOrchestrator(r, helpers.ResticBinary(t)) if err != nil { t.Fatalf("failed to create repo orchestrator: %v", err) } diff --git a/pkg/restic/restic_test.go b/pkg/restic/restic_test.go index ae86844a..c01f7d2d 100644 --- a/pkg/restic/restic_test.go +++ b/pkg/restic/restic_test.go @@ -9,7 +9,6 @@ import ( "slices" "testing" - v1 "github.com/garethgeorge/backrest/gen/go/v1" "github.com/garethgeorge/backrest/test/helpers" ) @@ -17,11 +16,7 @@ func TestResticInit(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) @@ -33,11 +28,7 @@ func TestResticBackup(t *testing.T) { repo := t.TempDir() // create a new repo with cache disabled for testing - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -120,11 +111,7 @@ func TestResticPartialBackup(t *testing.T) { repo := t.TempDir() // create a new repo with cache disabled for testing - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -162,11 +149,7 @@ func TestResticBackupLots(t *testing.T) { repo := t.TempDir() // create a new repo with cache disabled for testing - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -189,11 +172,7 @@ func TestSnapshot(t *testing.T) { repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -249,11 +228,7 @@ func TestLs(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -280,11 +255,7 @@ func TestResticForget(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -338,11 +309,7 @@ func TestForgetSnapshotId(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -377,11 +344,7 @@ func TestResticPrune(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -418,11 +381,7 @@ func TestResticRestore(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) } @@ -454,11 +413,7 @@ func TestResticStats(t *testing.T) { t.Parallel() repo := t.TempDir() - r := NewRepo(helpers.ResticBinary(t), &v1.Repo{ - Id: "test", - Uri: repo, - Password: "test", - }, WithFlags("--no-cache")) + r := NewRepo(helpers.ResticBinary(t), repo, WithFlags("--no-cache"), WithEnv("RESTIC_PASSWORD=test")) if err := r.Init(context.Background()); err != nil { t.Fatalf("failed to init repo: %v", err) }