github.com/anchore/syft@v1.38.2/syft/get_source_config_test.go (about) 1 package syft 2 3 import ( 4 "testing" 5 6 "github.com/anchore/stereoscope" 7 "github.com/anchore/syft/syft/source/sourceproviders" 8 ) 9 10 func TestGetProviders_DefaultImagePullSource(t *testing.T) { 11 userInput := "" 12 cfg := &GetSourceConfig{DefaultImagePullSource: stereoscope.RegistryTag} 13 allSourceProviders := sourceproviders.All(userInput, cfg.SourceProviderConfig) 14 15 providers, err := cfg.getProviders(userInput) 16 if err != nil { 17 t.Errorf("Expected no error for DefaultImagePullSource parameter, got: %v", err) 18 } 19 20 if len(providers) != len(allSourceProviders) { 21 t.Errorf("Expected %d providers, got %d", len(allSourceProviders), len(providers)) 22 } 23 } 24 25 func TestGetProviders_Sources(t *testing.T) { 26 userInput := "" 27 cfg := &GetSourceConfig{Sources: []string{stereoscope.RegistryTag}} 28 29 providers, err := cfg.getProviders(userInput) 30 if err != nil { 31 t.Errorf("Expected no error for Sources parameter, got: %v", err) 32 } 33 34 if len(providers) != 1 { 35 t.Errorf("Expected 1 providers, got %d", len(providers)) 36 } 37 }