2026-07-11 02:11:42 +05:30
|
|
|
package setup
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/safedep/pmg/internal/doctor"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestPathContainsDir(t *testing.T) {
|
|
|
|
|
assert.True(t, pathContainsDir([]string{"/usr/local/lib/pmg/bin/"}, "/usr/local/lib/pmg/bin"))
|
|
|
|
|
assert.False(t, pathContainsDir([]string{"/usr/local/bin"}, "/usr/local/lib/pmg/bin"))
|
|
|
|
|
assert.False(t, pathContainsDir([]string{"/usr/bin"}, ""))
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-13 15:37:02 +05:30
|
|
|
func TestSystemInstallAliasesPassDoesNotActivateInterception(t *testing.T) {
|
2026-07-11 02:11:42 +05:30
|
|
|
results := []doctor.CheckResult{
|
2026-07-13 15:37:02 +05:30
|
|
|
{Name: checkShellAliases, Status: doctor.StatusPass, Message: "No aliases (system install)"},
|
2026-07-11 02:11:42 +05:30
|
|
|
{Name: checkShimInPath, Status: doctor.StatusFail},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert.False(t, isInterceptionActive(results))
|
|
|
|
|
}
|
2026-07-13 15:37:02 +05:30
|
|
|
|
|
|
|
|
func TestAliasesInstalledActivatesInterception(t *testing.T) {
|
|
|
|
|
results := []doctor.CheckResult{
|
|
|
|
|
{Name: checkShellAliases, Status: doctor.StatusPass, Message: aliasesInstalledMessage},
|
|
|
|
|
{Name: checkShimInPath, Status: doctor.StatusFail},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert.True(t, isInterceptionActive(results))
|
|
|
|
|
}
|