syft/internal/formats/syftjson/model/linux_release_test.go
Alex Goodman 706f291679
Replace distro type (#742)
* 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>
2022-01-12 12:13:42 -05:00

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)
})
}
}