diff options
Diffstat (limited to 'internal/pkg/pkg_test.go')
| -rw-r--r-- | internal/pkg/pkg_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index ce11fa90..9a397898 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -1852,6 +1852,49 @@ func TestOpen(t *testing.T) { t.Errorf("Open: error = %#v, want %#v", err, wantErr) } }) + + t.Run("dirty", func(t *testing.T) { + t.Parallel() + + tempDir := check.MustAbs(t.TempDir()) + if err := os.MkdirAll(tempDir.Append( + "cache", + "work", + "dirty", + ).String(), 0755); err != nil { + t.Fatal(err) + } + + wantErr := errors.New("work is not empty, scrub likely required") + if _, err := pkg.Open( + t.Context(), + message.New(nil), + 0, 0, 0, tempDir.Append("cache"), + ); !reflect.DeepEqual(err, wantErr) { + t.Errorf("Open: error = %#v, want %#v", err, wantErr) + } + }) + + t.Run("scratch", func(t *testing.T) { + t.Parallel() + + tempDir := check.MustAbs(t.TempDir()) + if err := os.MkdirAll(tempDir.Append( + "cache", + "scratch", + ).String(), 0755); err != nil { + t.Fatal(err) + } + + wantErr := errors.New("scratch is present, scrub likely required") + if _, err := pkg.Open( + t.Context(), + message.New(nil), + 0, 0, 0, tempDir.Append("cache"), + ); !reflect.DeepEqual(err, wantErr) { + t.Errorf("Open: error = %#v, want %#v", err, wantErr) + } + }) } func TestExtensionRegister(t *testing.T) { |
