mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
rename testing license scanner
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
4fd1828ba9
commit
c5fba2d0e4
@ -35,9 +35,9 @@ func NewDefaultScanner() Scanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StaticScanner returns a scanner that uses the built-in license scanner from the licensecheck package.
|
// TestingOnlyScanner returns a scanner that uses the built-in license scanner from the licensecheck package.
|
||||||
// THIS IS ONLY MEANT FOR TEST CODE, NOT PRODUCTION CODE.
|
// THIS IS ONLY MEANT FOR TEST CODE, NOT PRODUCTION CODE.
|
||||||
func StaticScanner() Scanner {
|
func TestingOnlyScanner() Scanner {
|
||||||
return &scanner{
|
return &scanner{
|
||||||
coverageThreshold: coverageThreshold,
|
coverageThreshold: coverageThreshold,
|
||||||
scanner: licensecheck.Scan,
|
scanner: licensecheck.Scan,
|
||||||
|
|||||||
@ -28,7 +28,7 @@ func Test_LocalLicenseSearch(t *testing.T) {
|
|||||||
loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt")
|
loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt")
|
||||||
loc3 := file.NewLocation("github.com/someorg/strangelicense@v1.2.3/LiCeNsE.tXt")
|
loc3 := file.NewLocation("github.com/someorg/strangelicense@v1.2.3/LiCeNsE.tXt")
|
||||||
|
|
||||||
licenseScanner := licenses.StaticScanner()
|
licenseScanner := licenses.TestingOnlyScanner()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -96,7 +96,7 @@ func Test_RemoteProxyLicenseSearch(t *testing.T) {
|
|||||||
loc1 := file.NewLocation("github.com/someorg/somename@v0.3.2/LICENSE")
|
loc1 := file.NewLocation("github.com/someorg/somename@v0.3.2/LICENSE")
|
||||||
loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt")
|
loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt")
|
||||||
|
|
||||||
licenseScanner := licenses.StaticScanner()
|
licenseScanner := licenses.TestingOnlyScanner()
|
||||||
|
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
@ -254,7 +254,7 @@ func Test_findVersionPath(t *testing.T) {
|
|||||||
|
|
||||||
func Test_walkDirErrors(t *testing.T) {
|
func Test_walkDirErrors(t *testing.T) {
|
||||||
resolver := newGoLicenseResolver("", CatalogerConfig{})
|
resolver := newGoLicenseResolver("", CatalogerConfig{})
|
||||||
_, err := resolver.findLicensesInFS(context.Background(), licenses.StaticScanner(), "somewhere", badFS{})
|
_, err := resolver.findLicensesInFS(context.Background(), licenses.TestingOnlyScanner(), "somewhere", badFS{})
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ func Test_noLocalGoModDir(t *testing.T) {
|
|||||||
validTmp := t.TempDir()
|
validTmp := t.TempDir()
|
||||||
require.NoError(t, os.MkdirAll(filepath.Join(validTmp, "mod@ver"), 0700|os.ModeDir))
|
require.NoError(t, os.MkdirAll(filepath.Join(validTmp, "mod@ver"), 0700|os.ModeDir))
|
||||||
|
|
||||||
licenseScanner := licenses.StaticScanner()
|
licenseScanner := licenses.TestingOnlyScanner()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@ -169,7 +169,7 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
licenseScanner := licenses.StaticScanner()
|
licenseScanner := licenses.TestingOnlyScanner()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import (
|
|||||||
func TestSearchMavenForLicenses(t *testing.T) {
|
func TestSearchMavenForLicenses(t *testing.T) {
|
||||||
url := mockMavenRepo(t)
|
url := mockMavenRepo(t)
|
||||||
|
|
||||||
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner())
|
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -90,7 +90,7 @@ func TestSearchMavenForLicenses(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseJar(t *testing.T) {
|
func TestParseJar(t *testing.T) {
|
||||||
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner())
|
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -1354,7 +1354,7 @@ func Test_parseJavaArchive_regressions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_deterministicMatchingPomProperties(t *testing.T) {
|
func Test_deterministicMatchingPomProperties(t *testing.T) {
|
||||||
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner())
|
ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
fixture string
|
fixture string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user