mirror of
https://github.com/anchore/syft
synced 2024-11-10 06:14:16 +00:00
3eab5932e5
* deduplicate digests from user configuration Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * backout pointer reciever change on imageSource Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
44 lines
664 B
Go
44 lines
664 B
Go
package file
|
|
|
|
import (
|
|
"crypto"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNormalizeHashes(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
name string
|
|
input []crypto.Hash
|
|
want []crypto.Hash
|
|
}{
|
|
{
|
|
name: "deduplicate hashes",
|
|
input: []crypto.Hash{
|
|
crypto.SHA1,
|
|
crypto.SHA1,
|
|
},
|
|
want: []crypto.Hash{
|
|
crypto.SHA1,
|
|
},
|
|
},
|
|
{
|
|
name: "sort hashes",
|
|
input: []crypto.Hash{
|
|
crypto.SHA512,
|
|
crypto.SHA1,
|
|
},
|
|
want: []crypto.Hash{
|
|
crypto.SHA1,
|
|
crypto.SHA512,
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equal(t, tt.want, NormalizeHashes(tt.input))
|
|
})
|
|
}
|
|
}
|