MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / TestGetShortCommitHash_Success

Function TestGetShortCommitHash_Success

vcs/git/git_test.go:147–160  ·  view source on GitHub ↗

Tests for GetShortCommitHash

(t *testing.T)

Source from the content-addressed store, hash-verified

145// Tests for GetShortCommitHash
146
147func 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
162func TestGetShortCommitHash_AlreadyShort(t *testing.T) {
163 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 5

setupGitRepoFunction · 0.85
createFileFunction · 0.85
gitAddFunction · 0.85
gitCommitAndGetSHAFunction · 0.85
GetShortCommitHashFunction · 0.85

Tested by

no test coverage detected