(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func 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 | } |
nothing calls this directly
no test coverage detected