asdf/internal/paths/paths_test.go
Trevor Brown 7dfa8b40ae fix(golang-rewrite): asdf exec and asdf env command fixes
* Create `CurrentEnv` and `MergeEnv` helper functions
* Add another test for `paths.RemoveFromPath` function
* Move executable finding functions to shims package
* Correct PATH code for env and exec commands
2024-12-18 11:32:03 -05:00

25 lines
782 B
Go

package paths
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRemoveFromPath(t *testing.T) {
t.Run("returns PATH string with matching path removed", func(t *testing.T) {
got := RemoveFromPath("/foo/bar:/baz/bim:/home/user/bin", "/baz/bim")
assert.Equal(t, got, "/foo/bar:/home/user/bin")
})
t.Run("returns PATH string with multiple matching paths removed", func(t *testing.T) {
got := RemoveFromPath("/foo/bar:/baz/bim:/baz/bim:/home/user/bin", "/baz/bim")
assert.Equal(t, got, "/foo/bar:/home/user/bin")
})
t.Run("returns PATH string unchanged when no matching path found", func(t *testing.T) {
got := RemoveFromPath("/foo/bar:/baz/bim:/home/user/bin", "/path-not-present/")
assert.Equal(t, got, "/foo/bar:/baz/bim:/home/user/bin")
})
}