2
This commit is contained in:
@@ -94,3 +94,50 @@ func TestSerializeProducesSectionHeaders(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectSambaInstallPlanPrefersApt(t *testing.T) {
|
||||
lookPath := func(file string) (string, error) {
|
||||
switch file {
|
||||
case "apt-get", "sudo":
|
||||
return "/usr/bin/" + file, nil
|
||||
default:
|
||||
return "", execErr(file)
|
||||
}
|
||||
}
|
||||
|
||||
plan, ok := DetectSambaInstallPlan(lookPath, false)
|
||||
if !ok {
|
||||
t.Fatalf("expected install plan")
|
||||
}
|
||||
if plan.ManagerName != "apt" {
|
||||
t.Fatalf("expected apt manager, got %q", plan.ManagerName)
|
||||
}
|
||||
if plan.DisplayCommand() != "sudo sh -c apt-get update && apt-get install -y samba" {
|
||||
t.Fatalf("unexpected command: %q", plan.DisplayCommand())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectSambaInstallPlanWithoutSudo(t *testing.T) {
|
||||
lookPath := func(file string) (string, error) {
|
||||
switch file {
|
||||
case "pacman":
|
||||
return "/usr/bin/pacman", nil
|
||||
default:
|
||||
return "", execErr(file)
|
||||
}
|
||||
}
|
||||
|
||||
plan, ok := DetectSambaInstallPlan(lookPath, false)
|
||||
if !ok {
|
||||
t.Fatalf("expected install plan")
|
||||
}
|
||||
if plan.DisplayCommand() != "pacman -Sy --noconfirm samba" {
|
||||
t.Fatalf("unexpected command: %q", plan.DisplayCommand())
|
||||
}
|
||||
}
|
||||
|
||||
type execErr string
|
||||
|
||||
func (e execErr) Error() string {
|
||||
return "not found: " + string(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user