MCPcopy Index your code
hub / github.com/cli/cli / TestDigestAlgForRef

Function TestDigestAlgForRef

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

Source from the content-addressed store, hash-verified

94}
95
96func TestDigestAlgForRef(t *testing.T) {
97 tests := []struct {
98 name string
99 digest string
100 expected string
101 }{
102 {
103 name: "sha1 (40 hex chars)",
104 digest: "1234567890abcdef1234567890abcdef12345678",
105 expected: "sha1",
106 },
107 {
108 name: "sha256 (64 hex chars)",
109 digest: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
110 expected: "sha256",
111 },
112 {
113 name: "empty string defaults to sha1",
114 digest: "",
115 expected: "sha1",
116 },
117 {
118 name: "unexpected length defaults to sha1",
119 digest: "abc",
120 expected: "sha1",
121 },
122 }
123
124 for _, tt := range tests {
125 t.Run(tt.name, func(t *testing.T) {
126 assert.Equal(t, tt.expected, DigestAlgForRef(tt.digest))
127 })
128 }
129}

Callers

nothing calls this directly

Calls 3

DigestAlgForRefFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected