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

     1  package python_test
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  
     7  	"github.com/apex/log"
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"github.com/fossas/fossa-cli/analyzers"
    11  	"github.com/fossas/fossa-cli/module"
    12  	"github.com/fossas/fossa-cli/pkg"
    13  	"github.com/fossas/fossa-cli/testing/fixtures"
    14  	"github.com/fossas/fossa-cli/testing/runfossa"
    15  )
    16  
    17  var pythonAnalyzerFixtureDir = filepath.Join(fixtures.Directory(), "python", "analyzer")
    18  
    19  func TestPythonIntegration(t *testing.T) {
    20  	if testing.Short() {
    21  		t.Skip("Integration tests to not run with the -short test flag")
    22  	}
    23  	t.Parallel()
    24  
    25  	// err := fixtures.Clone(pythonAnalyzerFixtureDir, projects)
    26  	fixtures.Initialize(pythonAnalyzerFixtureDir, projects, func(proj fixtures.Project, projectDir string) error {
    27  		stdout, stderr, err := runfossa.Init(projectDir)
    28  		if err != nil {
    29  			log.Error("failed to run fossa init on " + proj.Name)
    30  			log.Error(stdout)
    31  			log.Error(stderr)
    32  			return err
    33  		}
    34  
    35  		return nil
    36  	})
    37  	for _, project := range projects {
    38  		proj := project
    39  		projDir := filepath.Join(pythonAnalyzerFixtureDir, proj.Name)
    40  		t.Run("Analysis:"+proj.Name, func(t *testing.T) {
    41  			t.Parallel()
    42  			module := module.Module{
    43  				Dir:         projDir,
    44  				Type:        pkg.Python,
    45  				Name:        proj.Name,
    46  				Options:     map[string]interface{}{},
    47  				BuildTarget: projDir,
    48  			}
    49  
    50  			analyzer, err := analyzers.New(module)
    51  			assert.NoError(t, err)
    52  
    53  			deps, err := analyzer.Analyze()
    54  			assert.NoError(t, err)
    55  
    56  			assert.NotEmpty(t, deps.Direct)
    57  			assert.NotEmpty(t, deps.Transitive)
    58  		})
    59  	}
    60  }
    61  
    62  var projects = []fixtures.Project{
    63  	fixtures.Project{
    64  		Name:   "vibora",
    65  		URL:    "https://github.com/vibora-io/vibora",
    66  		Commit: "51d6691a430bbb6ac57df54dc7d8276f62953bb2",
    67  	},
    68  	// sentry seg faults on pip install. This is linked to the particular commit. This can be resolved down the line once native integration tests are stable
    69  	// fixtures.Project{
    70  	// 	Name:   "sentry",
    71  	// 	URL:    "https://github.com/getsentry/sentry",
    72  	// 	Commit: "985a917353d23caa112d133cfa6873389d831be5",
    73  	// },
    74  	// The original fixture docker image contained the projects listed below, however the test.sh file did not test them
    75  	// For this reason, these will remain untested until we reach test parity with the previous integraiton tests.
    76  	// TODO: support the fixture cases listed below. Note that the circle cache number will need to be updated for this to take effect
    77  	// fixtures.Project{
    78  	// 	Name:   "ansible",
    79  	// 	URL:    "https://github.com/ansible/ansible",
    80  	// 	Commit: "649403c3a179277ec2ad7373962cb7baee2f715f",
    81  	// },
    82  	// fixtures.Project{
    83  	// 	Name:   "fabric",
    84  	// 	URL:    "https://github.com/fabric/fabric",
    85  	// 	Commit: "c37df4cae043eee3b6c5fc39a98d72437b45a938",
    86  	// },
    87  	// fixtures.Project{
    88  	// 	Name:   "boto",
    89  	// 	URL:    "https://github.com/boto/boto",
    90  	// 	Commit: "eca5f987aa59ec7490aa91466853c36b0cf40b3c",
    91  	// },
    92  	// fixtures.Project{
    93  	// 	Name:   "NewsBlur",
    94  	// 	URL:    "https://github.com/samuelclay/NewsBlur",
    95  	// 	Commit: "121daffcdae4bc324cf6e81f095e28529e81372d",
    96  	// },
    97  	// fixtures.Project{
    98  	// 	Name:   "legit",
    99  	// 	URL:    "https://github.com/kennethreitz/legit",
   100  	// 	Commit: "20187b45ce4d32146d2a2d493c315924c1cc8287",
   101  	// },
   102  	// fixtures.Project{
   103  	// 	Name:   "sshuttle",
   104  	// 	URL:    "https://github.com/sshuttle/sshuttle",
   105  	// 	Commit: "6dc368bde8128cd27ad80d48772420ff68a92c8f",
   106  	// },
   107  }