mirror of
https://github.com/anchore/syft.git
synced 2026-02-15 12:06:41 +01:00
--------- Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package syft
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/stereoscope"
|
|
"github.com/anchore/syft/syft/source/sourceproviders"
|
|
)
|
|
|
|
func TestGetProviders_DefaultImagePullSource(t *testing.T) {
|
|
userInput := ""
|
|
cfg := &GetSourceConfig{DefaultImagePullSource: stereoscope.RegistryTag}
|
|
allSourceProviders := sourceproviders.All(userInput, cfg.SourceProviderConfig)
|
|
|
|
providers, err := cfg.getProviders(userInput)
|
|
if err != nil {
|
|
t.Errorf("Expected no error for DefaultImagePullSource parameter, got: %v", err)
|
|
}
|
|
|
|
if len(providers) != len(allSourceProviders) {
|
|
t.Errorf("Expected %d providers, got %d", len(allSourceProviders), len(providers))
|
|
}
|
|
}
|
|
|
|
func TestGetProviders_Sources(t *testing.T) {
|
|
userInput := ""
|
|
cfg := &GetSourceConfig{Sources: []string{stereoscope.RegistryTag}}
|
|
|
|
providers, err := cfg.getProviders(userInput)
|
|
if err != nil {
|
|
t.Errorf("Expected no error for Sources parameter, got: %v", err)
|
|
}
|
|
|
|
// Registry tag has two providers: OCIModel and Image
|
|
if len(providers) != 2 {
|
|
t.Errorf("Expected 2 providers, got %d", len(providers))
|
|
}
|
|
}
|