Tests for GetShortCommitHash
(t *testing.T)
| 145 | // Tests for GetShortCommitHash |
| 146 | |
| 147 | func TestGetShortCommitHash_Success(t *testing.T) { |
| 148 | tmpDir := t.TempDir() |
| 149 | setupGitRepo(t, tmpDir) |
| 150 | |
| 151 | createFile(t, tmpDir, "test.txt", "content") |
| 152 | gitAdd(t, tmpDir, "test.txt") |
| 153 | fullHash := gitCommitAndGetSHA(t, tmpDir, "Initial commit") |
| 154 | |
| 155 | shortHash, err := GetShortCommitHash(tmpDir, fullHash) |
| 156 | |
| 157 | require.NoError(t, err) |
| 158 | assert.True(t, len(shortHash) >= 7 && len(shortHash) <= 12) |
| 159 | assert.True(t, strings.HasPrefix(fullHash, shortHash)) |
| 160 | } |
| 161 | |
| 162 | func TestGetShortCommitHash_AlreadyShort(t *testing.T) { |
| 163 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected