| 151 | } |
| 152 | |
| 153 | func TestExpandConfigPath(t *testing.T) { |
| 154 | os.Unsetenv("XDG_CONFIG_HOME") |
| 155 | for desc, c := range map[string]*ExpandConfigPathTestCase{ |
| 156 | "unexpanded full path": { |
| 157 | Path: "/path/to/attributes", |
| 158 | Want: "/path/to/attributes", |
| 159 | }, |
| 160 | "expanded full path": { |
| 161 | Path: "~/path/to/attributes", |
| 162 | Want: "/home/pat/path/to/attributes", |
| 163 | currentUser: func() (*user.User, error) { |
| 164 | return &user.User{ |
| 165 | HomeDir: "/home/pat", |
| 166 | }, nil |
| 167 | }, |
| 168 | }, |
| 169 | "expanded default path": { |
| 170 | DefaultPath: "git/attributes", |
| 171 | Want: "/home/pat/.config/git/attributes", |
| 172 | currentUser: func() (*user.User, error) { |
| 173 | return &user.User{ |
| 174 | HomeDir: "/home/pat", |
| 175 | }, nil |
| 176 | }, |
| 177 | }, |
| 178 | "XDG_CONFIG_HOME set": { |
| 179 | DefaultPath: "git/attributes", |
| 180 | Want: "/home/pat/configpath/git/attributes", |
| 181 | lookupConfigHome: func() string { |
| 182 | return "/home/pat/configpath" |
| 183 | }, |
| 184 | }, |
| 185 | } { |
| 186 | t.Run(desc, c.Assert) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | func TestFastWalkBasic(t *testing.T) { |
| 191 | wd, err := os.Getwd() |