| 333 | } |
| 334 | |
| 335 | func TestShortRev(t *testing.T) { |
| 336 | // GitHub refs only parse as "locked" (with a Rev) if the third path |
| 337 | // component is a 40-char hex SHA. Anything shorter is treated as a ref |
| 338 | // name, not a revision. |
| 339 | longRev := "abc1234def56789012345678901234567890abcd" |
| 340 | cases := []struct { |
| 341 | in, want string |
| 342 | }{ |
| 343 | {"github:numtide/flake-utils/" + longRev + "#pkg", "abc1234"}, |
| 344 | {"path:./local", ""}, |
| 345 | {"", ""}, |
| 346 | {"not a flake ref", ""}, |
| 347 | } |
| 348 | for _, tc := range cases { |
| 349 | t.Run(tc.in, func(t *testing.T) { |
| 350 | require.Equal(t, tc.want, shortRev(tc.in)) |
| 351 | }) |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | func TestShortDate(t *testing.T) { |
| 356 | require.Equal(t, "2025-04-22", shortDate("2025-04-22T14:30:00Z")) |