github.com/tiagovtristao/plz@v13.4.0+incompatible/src/fs/home_test.go (about)

     1  package fs
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestExpandHomePath(t *testing.T) {
    11  	HOME := os.Getenv("HOME")
    12  	cases := []struct {
    13  		in, want string
    14  	}{
    15  		{"", ""},
    16  		{"~", HOME},
    17  		{"~username", "~username"},
    18  		{"~:/bin/~:/usr/local", HOME + ":/bin/~:/usr/local"},
    19  		{"/bin:~/bin:~/script:/usr/local/bin",
    20  			"/bin:" + HOME + "/bin:" + HOME + "/script:/usr/local/bin"},
    21  	}
    22  	for _, c := range cases {
    23  		assert.Equal(t, c.want, ExpandHomePath(c.in))
    24  	}
    25  }