mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* remove strong distro type Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * bump json schema to v3 (breaking distro shape) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * allow for v2 decoding of distro idLikes field in v3 json decoder Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix casing in simple linux release name Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * use discovered name as pretty name in simple linux release Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
48 lines
835 B
Go
48 lines
835 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIDLikes_UnmarshalJSON(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
data interface{}
|
|
expected IDLikes
|
|
}{
|
|
{
|
|
name: "single string",
|
|
data: "well hello there!",
|
|
expected: IDLikes{
|
|
"well hello there!",
|
|
},
|
|
},
|
|
{
|
|
name: "multiple strings",
|
|
data: []string{
|
|
"well hello there!",
|
|
"...hello there, john!",
|
|
},
|
|
expected: IDLikes{
|
|
"well hello there!",
|
|
"...hello there, john!",
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
data, err := json.Marshal(&tt.data)
|
|
require.NoError(t, err)
|
|
|
|
var obj IDLikes
|
|
require.NoError(t, json.Unmarshal(data, &obj))
|
|
|
|
assert.Equal(t, tt.expected, obj)
|
|
})
|
|
}
|
|
}
|