(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestShellExpand(t *testing.T) { |
| 14 | home, err := homedir.Dir() |
| 15 | require.NoError(t, err) |
| 16 | require.NoError(t, os.Setenv("EXPAND_TEST", "potato")) |
| 17 | defer func() { |
| 18 | require.NoError(t, os.Unsetenv("EXPAND_TEST")) |
| 19 | }() |
| 20 | for _, test := range []struct { |
| 21 | in, want string |
| 22 | }{ |
| 23 | {"", ""}, |
| 24 | {"~", filepath.FromSlash(home)}, |
| 25 | {filepath.FromSlash("~/dir/file.txt"), filepath.FromSlash(home + "/dir/file.txt")}, |
| 26 | {filepath.FromSlash("/dir/~/file.txt"), filepath.FromSlash("/dir/~/file.txt")}, |
| 27 | {filepath.FromSlash("~/${EXPAND_TEST}"), filepath.FromSlash(home + "/potato")}, |
| 28 | } { |
| 29 | got := ShellExpand(test.in) |
| 30 | assert.Equal(t, test.want, got, test.in) |
| 31 | } |
| 32 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…