github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/analyzers/gradle/integration_test.go (about) 1 package gradle_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/exec" 11 "github.com/fossas/fossa-cli/testing/fixtures" 12 "github.com/fossas/fossa-cli/testing/runfossa" 13 ) 14 15 var ( 16 fixtureDir = filepath.Join(fixtures.Directory(), "gradle", "analyzer") 17 grpc = fixtures.Project{ 18 Name: "grpc-java", 19 URL: "https://github.com/grpc/grpc-java", 20 Commit: "cf083239e7cbbde7e8ed7d3f038202735f84c2d3", 21 } 22 projects = []fixtures.Project{grpc} 23 ) 24 25 func TestGradleIntegration(t *testing.T) { 26 if testing.Short() { 27 t.Skip("Skip integration test") 28 } 29 30 fixtures.Initialize(fixtureDir, projects, func(p fixtures.Project, dir string) error { 31 args := []string{"build", "-p", dir} 32 command := filepath.Join(dir, "gradlew") 33 _, stderr, err := exec.Run(exec.Cmd{ 34 Name: command, 35 Argv: args, 36 }) 37 if err != nil { 38 log.Error("Error running ./gradlew") 39 log.Error(stderr) 40 } 41 42 _, _, err = runfossa.Init(dir) 43 assert.NoError(t, err) 44 45 return nil 46 }) 47 48 targets := map[string]string{ 49 grpc.Name: "gradle:grpc-netty", 50 } 51 52 for project, target := range targets { 53 output, err := runfossa.AnalyzeOutput(filepath.Join(fixtureDir, project), []string{target}) 54 assert.NoError(t, err) 55 assert.NotEmpty(t, output) 56 assert.NotEmpty(t, output[0].Build.Dependencies) 57 assert.NotEmpty(t, output[0].Build.Imports) 58 t.Logf("%#v", output) 59 } 60 }