github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/buildtools/bundler/lockfile_test.go (about) 1 package bundler_test 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 "github.com/fossas/fossa-cli/buildtools/bundler" 10 ) 11 12 // TODO: we should make sure this is exactly correct, using a struct fixture. 13 func TestLockfileParsing(t *testing.T) { 14 l, err := bundler.FromLockfile(filepath.Join("testdata", "Gemfile.lock")) 15 assert.NoError(t, err) 16 17 testSections(t, l.Git) 18 testSections(t, l.Path) 19 testSections(t, l.Gem) 20 assert.NotEmpty(t, l.Dependencies) 21 22 t.Logf("%#v", l) 23 } 24 25 func TestBadLockfileParsing(t *testing.T) { 26 l, err := bundler.FromLockfile(filepath.Join("testdata", "BadGemfile.lock")) 27 assert.NoError(t, err) 28 assert.Empty(t, l.Dependencies) 29 t.Logf("%#v", l) 30 } 31 32 func testSections(t *testing.T, sections []bundler.Section) { 33 for _, section := range sections { 34 assert.NotEmpty(t, section.Specs) 35 for _, spec := range section.Specs { 36 assert.NotZero(t, spec) 37 assert.NotEmpty(t, spec.Name) 38 } 39 } 40 }