| 11 | ) |
| 12 | |
| 13 | func TestResolve(t *testing.T) { |
| 14 | cwd, err := os.Getwd() |
| 15 | assert.NoError(t, err) |
| 16 | |
| 17 | testCases := []struct { |
| 18 | in, out string |
| 19 | }{ |
| 20 | {"", ""}, // don't make wild guesses |
| 21 | {"/home/alice///foobar", "/home/alice/foobar"}, |
| 22 | {"~/foobar", "/home/alice/foobar"}, |
| 23 | {"/foobar/~/noexpand", "/foobar/~/noexpand"}, |
| 24 | {"/no/modification", "/no/modification"}, |
| 25 | {"relative", filepath.Join(cwd, "relative")}, |
| 26 | {"relative///path", filepath.Join(cwd, "relative", "path")}, |
| 27 | } |
| 28 | |
| 29 | for _, tc := range testCases { |
| 30 | testName := "'" + tc.in + "' should be normalized as '" + tc.out + "'" |
| 31 | t.Run(testName, func(t *testing.T) { |
| 32 | assert.Equal(t, tc.out, Resolve(tc.in, "/home/alice"), testName) |
| 33 | }) |
| 34 | } |
| 35 | } |