MCPcopy
hub / github.com/rclone/rclone / TestShellExpand

Function TestShellExpand

lib/env/env_test.go:13–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func 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}

Callers

nothing calls this directly

Calls 4

ShellExpandFunction · 0.85
DirMethod · 0.80
SetenvMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…