(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func TestResolvePaths(t *testing.T) { //nolint:tparallel // subtests using t.Setenv cannot be parallel |
| 90 | t.Run("EmptyString", func(t *testing.T) { |
| 91 | t.Parallel() |
| 92 | require.Nil(t, agentcontextconfig.ResolvePaths("", platformAbsPath("base"))) |
| 93 | }) |
| 94 | |
| 95 | t.Run("WhitespaceOnly", func(t *testing.T) { |
| 96 | t.Parallel() |
| 97 | require.Nil(t, agentcontextconfig.ResolvePaths(" ", platformAbsPath("base"))) |
| 98 | }) |
| 99 | |
| 100 | t.Run("SingleEntry", func(t *testing.T) { |
| 101 | t.Parallel() |
| 102 | p := platformAbsPath("abs", "path") |
| 103 | got := agentcontextconfig.ResolvePaths(p, platformAbsPath("base")) |
| 104 | require.Equal(t, []string{p}, got) |
| 105 | }) |
| 106 | |
| 107 | // Tests that use t.Setenv cannot be parallel. |
| 108 | t.Run("MultipleEntries", func(t *testing.T) { |
| 109 | fakeHome := t.TempDir() |
| 110 | t.Setenv("HOME", fakeHome) |
| 111 | t.Setenv("USERPROFILE", fakeHome) |
| 112 | b := platformAbsPath("b") |
| 113 | base := platformAbsPath("base") |
| 114 | got := agentcontextconfig.ResolvePaths("~/a,"+b+",rel", base) |
| 115 | require.Equal(t, []string{ |
| 116 | filepath.Join(fakeHome, "a"), |
| 117 | b, |
| 118 | filepath.Join(base, "rel"), |
| 119 | }, got) |
| 120 | }) |
| 121 | |
| 122 | t.Run("TrimsWhitespace", func(t *testing.T) { |
| 123 | t.Parallel() |
| 124 | a := platformAbsPath("a") |
| 125 | b := platformAbsPath("b") |
| 126 | got := agentcontextconfig.ResolvePaths(" "+a+" , "+b+" ", platformAbsPath("base")) |
| 127 | require.Equal(t, []string{a, b}, got) |
| 128 | }) |
| 129 | |
| 130 | t.Run("SkipsEmptyEntries", func(t *testing.T) { |
| 131 | t.Parallel() |
| 132 | a := platformAbsPath("a") |
| 133 | b := platformAbsPath("b") |
| 134 | got := agentcontextconfig.ResolvePaths(a+",,"+b+",", platformAbsPath("base")) |
| 135 | require.Equal(t, []string{a, b}, got) |
| 136 | }) |
| 137 | |
| 138 | t.Run("TrailingComma", func(t *testing.T) { |
| 139 | t.Parallel() |
| 140 | p := platformAbsPath("only") |
| 141 | got := agentcontextconfig.ResolvePaths(p+",", platformAbsPath("base")) |
| 142 | require.Equal(t, []string{p}, got) |
| 143 | }) |
| 144 | |
| 145 | t.Run("RelativePathSkippedWhenBaseDirEmpty", func(t *testing.T) { |
| 146 | fakeHome := t.TempDir() |
nothing calls this directly
no test coverage detected