github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/buildtools/carthage/cartfile_test.go (about) 1 package carthage_test 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "path/filepath" 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 11 "github.com/fossas/fossa-cli/buildtools/carthage" 12 "github.com/fossas/fossa-cli/pkg" 13 ) 14 15 func TestCartfileParsing(t *testing.T) { 16 carthagePackage, err := carthage.FromResolvedCartfile("TestProject", filepath.Join("testdata", "testproject")) 17 assert.NoError(t, err) 18 19 data, err := json.Marshal(carthagePackage) 20 assert.NoError(t, err) 21 fmt.Printf("Imports: %s", string(data)) 22 23 deps := make(map[pkg.ID]pkg.Package) 24 carthage.RecurseDeps(deps, carthagePackage) 25 26 assert.Len(t, deps, 5, "Deps length should be 5") 27 28 for _, dep := range deps { 29 if dep.ID.Name == "https://github.com/Quick/Nimble" && dep.ID.Revision == "v7.1.3" { 30 assert.Len(t, dep.Imports, 2, "Should have 2 deps") 31 assert.Contains(t, dep.Imports, pkg.Import{ 32 Target: "githubhttps://github.com/mattgallagher/CwlCatchExceptionb14c111e9b33cd142bd4bc75c482cfd5c3490923", 33 Resolved: pkg.ID{ 34 Type: pkg.Carthage, 35 Name: "https://github.com/mattgallagher/CwlCatchException", 36 Revision: "b14c111e9b33cd142bd4bc75c482cfd5c3490923", 37 }, 38 }) 39 assert.Contains(t, dep.Imports, pkg.Import{ 40 Target: "githubhttps://github.com/mattgallagher/CwlPreconditionTesting1e62a726d54c743f4585233f08fcaac7307319b5", 41 Resolved: pkg.ID{ 42 Type: pkg.Carthage, 43 Name: "https://github.com/mattgallagher/CwlPreconditionTesting", 44 Revision: "1e62a726d54c743f4585233f08fcaac7307319b5", 45 }, 46 }) 47 } 48 } 49 50 fmt.Printf("Deps: %#v", deps) 51 52 } 53 54 func TestNoPanicOnEmptyFile(t *testing.T) { 55 _, err := carthage.FromResolvedCartfile("TestProject", filepath.Join("testdata", "testempty")) 56 assert.NoError(t, err) 57 }