(t *testing.T)
| 275 | } |
| 276 | |
| 277 | func TestExpandTilde(t *testing.T) { |
| 278 | home, err := os.UserHomeDir() |
| 279 | if err != nil { |
| 280 | t.Skip("cannot get home dir") |
| 281 | } |
| 282 | |
| 283 | tests := []struct { |
| 284 | input string |
| 285 | expected string |
| 286 | }{ |
| 287 | {"~/foo/bar", filepath.Join(home, "foo/bar")}, |
| 288 | {"~", home}, |
| 289 | {"/absolute/path", "/absolute/path"}, |
| 290 | {"relative/path", "relative/path"}, |
| 291 | } |
| 292 | |
| 293 | for _, tt := range tests { |
| 294 | got, err := expandTilde(tt.input) |
| 295 | if err != nil { |
| 296 | t.Errorf("expandTilde(%q): unexpected error: %v", tt.input, err) |
| 297 | continue |
| 298 | } |
| 299 | if got != tt.expected { |
| 300 | t.Errorf("expandTilde(%q) = %q, want %q", tt.input, got, tt.expected) |
| 301 | } |
| 302 | } |
| 303 | } |
nothing calls this directly
no test coverage detected