e5b9b233b8
'command' is a shell builtin, not a real binary, so exec.Command always failed with exit 127. Replaced with os/exec.LookPath which correctly resolves binaries in PATH. Also adds capabilities_test.go to verify Probe() matches exec.LookPath results. Version: 0.7.2
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"testing"
|
|
)
|
|
|
|
func TestProbeDetectsRsync(t *testing.T) {
|
|
caps, err := Probe(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("Probe: %v", err)
|
|
}
|
|
_, rsyncErr := exec.LookPath("rsync")
|
|
if rsyncErr != nil && caps.Rsync {
|
|
t.Error("Probe claims rsync is available but exec.LookPath says it is not")
|
|
}
|
|
if rsyncErr == nil && !caps.Rsync {
|
|
t.Error("exec.LookPath found rsync but Probe did not detect it")
|
|
}
|
|
}
|
|
|
|
func TestProbeDetectsSnapraid(t *testing.T) {
|
|
caps, err := Probe(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("Probe: %v", err)
|
|
}
|
|
_, snapraidErr := exec.LookPath("snapraid")
|
|
if snapraidErr != nil && caps.SnapraidBin {
|
|
t.Error("Probe claims snapraid is available but exec.LookPath says it is not")
|
|
}
|
|
if snapraidErr == nil && !caps.SnapraidBin {
|
|
t.Error("exec.LookPath found snapraid but Probe did not detect it")
|
|
}
|
|
}
|
|
|
|
func TestProbeDetectsMergerfsBin(t *testing.T) {
|
|
caps, err := Probe(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("Probe: %v", err)
|
|
}
|
|
_, mergerfsErr := exec.LookPath("mergerfs")
|
|
if mergerfsErr != nil && caps.MergerfsBin {
|
|
t.Error("Probe claims mergerfs is available but exec.LookPath says it is not")
|
|
}
|
|
if mergerfsErr == nil && !caps.MergerfsBin {
|
|
t.Error("exec.LookPath found mergerfs but Probe did not detect it")
|
|
}
|
|
}
|