github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/analyzers/nodejs/nodejs_discover_test.go (about) 1 package nodejs_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/fossas/fossa-cli/analyzers/nodejs" 9 "github.com/fossas/fossa-cli/module" 10 "github.com/fossas/fossa-cli/pkg" 11 ) 12 13 /* Nested Module Order 14 └─┬ nested-modules 15 └─┬ module-1 16 ├── module-2 17 └── module-3 18 */ 19 func TestNestedModules(t *testing.T) { 20 modules, err := nodejs.Discover("testdata/nested-modules", make(map[string]interface{})) 21 assert.NoError(t, err) 22 assert.Equal(t, len(modules), 4) 23 assert.Contains(t, modules, newModule("nested-modules", ".")) 24 assert.Contains(t, modules, newModule("module-1", "module-1")) 25 assert.Contains(t, modules, newModule("module-2", "module-1/module-2")) 26 assert.Contains(t, modules, newModule("module-3", "module-1/module-3")) 27 } 28 29 /* Ignored Module Order 30 └─┬ ignored-modules 31 ├── node_modules 32 └── bower_components 33 */ 34 func TestNodeModulesAndBowerIgnored(t *testing.T) { 35 modules, err := nodejs.Discover("testdata/ignored-modules", make(map[string]interface{})) 36 assert.NoError(t, err) 37 assert.Equal(t, len(modules), 1) 38 assert.Contains(t, modules, newModule("ignored-modules", ".")) 39 } 40 41 func newModule(name, location string) module.Module { 42 return module.Module{ 43 Name: name, 44 Type: pkg.NodeJS, 45 BuildTarget: location, 46 Dir: location, 47 } 48 }