github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/analyzers/nuget/nuget_test.go (about)

     1  package nuget_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/fossas/fossa-cli/analyzers/nuget"
     9  	"github.com/fossas/fossa-cli/module"
    10  	"github.com/fossas/fossa-cli/pkg"
    11  )
    12  
    13  func TestNugetDiscovery(t *testing.T) {
    14  	packagesConfig := module.Module{
    15  		Name:        "testdata/discovery/packages",
    16  		Type:        pkg.NuGet,
    17  		BuildTarget: "testdata/discovery/packages",
    18  		Dir:         "testdata/discovery/packages",
    19  	}
    20  	nuspec := module.Module{
    21  		Name:        "NUnit",
    22  		Type:        pkg.NuGet,
    23  		BuildTarget: "testdata/discovery/nuspec/temp.nuspec",
    24  		Dir:         "testdata/discovery/nuspec",
    25  	}
    26  	packageReference := module.Module{
    27  		Name:        "TestPackage",
    28  		Type:        pkg.NuGet,
    29  		BuildTarget: "testdata/discovery/package-reference-priority/temp.csproj",
    30  		Dir:         "testdata/discovery/package-reference-priority",
    31  	}
    32  	projectJSON := module.Module{
    33  		Name:        "testdata/discovery/project",
    34  		Type:        pkg.NuGet,
    35  		BuildTarget: "testdata/discovery/project",
    36  		Dir:         "testdata/discovery/project",
    37  	}
    38  
    39  	modules, err := nuget.Discover("testdata/discovery", nil)
    40  	assert.NoError(t, err)
    41  	assert.Len(t, modules, 4)
    42  	assert.Contains(t, modules, packagesConfig)
    43  	assert.Contains(t, modules, packageReference)
    44  	assert.Contains(t, modules, projectJSON)
    45  	assert.Contains(t, modules, nuspec)
    46  }