MCPcopy Create free account
hub / github.com/cli/cli / TestDigestAlgForRef

Function TestDigestAlgForRef

pkg/cmd/release/shared/fetch_test.go:184–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestDigestAlgForRef(t *testing.T) {
185 tests := []struct {
186 name string
187 digest string
188 expected string
189 }{
190 {
191 name: "sha1 (40 hex chars)",
192 digest: "1234567890abcdef1234567890abcdef12345678",
193 expected: "sha1",
194 },
195 {
196 name: "sha256 (64 hex chars)",
197 digest: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
198 expected: "sha256",
199 },
200 {
201 name: "empty string defaults to sha1",
202 digest: "",
203 expected: "sha1",
204 },
205 {
206 name: "unexpected length defaults to sha1",
207 digest: "abc",
208 expected: "sha1",
209 },
210 }
211
212 for _, tt := range tests {
213 t.Run(tt.name, func(t *testing.T) {
214 assert.Equal(t, tt.expected, DigestAlgForRef(tt.digest))
215 })
216 }
217}

Callers

nothing calls this directly

Calls 3

DigestAlgForRefFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected