github.com/delicb/asdf-exec@v0.1.3-0.20220111003559-af5f44250ab7/utils_test.go (about)

     1  package main
     2  
     3  import (
     4  	"os"
     5  	"path"
     6  	"strings"
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestReadLines(t *testing.T) {
    13  	assert.Equal(t, []string{"foo", "bar"}, ReadLines("foo\nbar"))
    14  	assert.Equal(t, []string{"foo", "bar"}, ReadLines("# hello\nfoo #bar \n  bar  "))
    15  }
    16  
    17  func TestRemoveAsdfPath(t *testing.T) {
    18  	asdfShimPath := path.Join(GetAsdfDataPath(), "shims")
    19  	home := os.Getenv("HOME")
    20  	homeBin := path.Join(home, "bin")
    21  
    22  	currentPath := []string{homeBin, asdfShimPath, "/usr/bin", "/bin"}
    23  	actualPath := RemoveAsdfPath(strings.Join(currentPath, ":"))
    24  	expectedPath := strings.Join([]string{homeBin, "/usr/bin", "/bin"}, ":")
    25  	assert.Equal(t, expectedPath, actualPath)
    26  }