mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fix: default image source name to user input (#1979)
* fix: default image source name to user input Signed-off-by: Keith Zantow <kzantow@gmail.com> * chore: add test Signed-off-by: Keith Zantow <kzantow@gmail.com> --------- Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
f14742b3f3
commit
e2f7befbfb
@ -109,8 +109,6 @@ func (s StereoscopeImageSource) Describe() Description {
|
||||
} else {
|
||||
if ref, ok := ref.(reference.Named); ok {
|
||||
nameIfUnset(ref.Name())
|
||||
} else {
|
||||
nameIfUnset(s.metadata.UserInput)
|
||||
}
|
||||
|
||||
if ref, ok := ref.(reference.NamedTagged); ok {
|
||||
@ -122,6 +120,7 @@ func (s StereoscopeImageSource) Describe() Description {
|
||||
}
|
||||
}
|
||||
|
||||
nameIfUnset(s.metadata.UserInput)
|
||||
versionIfUnset(s.metadata.ManifestDigest)
|
||||
|
||||
return Description{
|
||||
|
||||
@ -241,3 +241,31 @@ func Test_StereoscopeImageSource_ID(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Describe(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
source StereoscopeImageSource
|
||||
expected Description
|
||||
}{
|
||||
{
|
||||
name: "name from user input",
|
||||
source: StereoscopeImageSource{
|
||||
id: "some-id",
|
||||
metadata: StereoscopeImageSourceMetadata{
|
||||
UserInput: "user input",
|
||||
},
|
||||
},
|
||||
expected: Description{
|
||||
ID: "some-id",
|
||||
Name: "user input",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got := test.source.Describe()
|
||||
got.Metadata = nil // might want to test this, but do not to determine if the user input is userd
|
||||
require.Equal(t, test.expected, got)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user