Create named subdirectories for new repositories
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.casaderoll.de/michael/urbm/internal/model"
|
||||
)
|
||||
|
||||
func TestExternalMountAllowsNewRepositorySubdirectory(t *testing.T) {
|
||||
base := t.TempDir()
|
||||
repo := model.Repository{Type: model.RepositorySMB, Location: filepath.Join(base, "Photos")}
|
||||
manager := &MountManager{}
|
||||
|
||||
mounted, err := manager.Prepare(context.Background(), repo)
|
||||
if err != nil {
|
||||
t.Fatalf("new repository subdirectory rejected: %v", err)
|
||||
}
|
||||
if mounted.Repository.Location != repo.Location {
|
||||
t.Fatalf("location = %q, want %q", mounted.Repository.Location, repo.Location)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExternalMountRejectsMissingBaseDirectory(t *testing.T) {
|
||||
repo := model.Repository{Type: model.RepositoryNFS, Location: filepath.Join(t.TempDir(), "missing", "Photos")}
|
||||
manager := &MountManager{}
|
||||
|
||||
if _, err := manager.Prepare(context.Background(), repo); err == nil {
|
||||
t.Fatal("missing external mount base accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user