| 1861 | } |
| 1862 | |
| 1863 | func TestShortSHA(t *testing.T) { |
| 1864 | tests := []struct { |
| 1865 | name string |
| 1866 | sha string |
| 1867 | want string |
| 1868 | }{ |
| 1869 | {name: "long SHA", sha: "abc123def456789", want: "abc123de"}, |
| 1870 | {name: "short value", sha: "short", want: "short"}, |
| 1871 | } |
| 1872 | |
| 1873 | for _, tt := range tests { |
| 1874 | t.Run(tt.name, func(t *testing.T) { |
| 1875 | // Given a commit identifier |
| 1876 | sha := tt.sha |
| 1877 | |
| 1878 | // When it is shortened for display |
| 1879 | shortSHA := ShortSHA(sha) |
| 1880 | |
| 1881 | // Then at most the first eight characters are returned |
| 1882 | assert.Equal(t, tt.want, shortSHA) |
| 1883 | }) |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | func TestParseWorktrees(t *testing.T) { |
| 1888 | tests := []struct { |