Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
fix: actually export the Dependency struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoops committed Sep 2, 2020
1 parent a624f8d commit 05bf80f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ type Bitmask uint32

// Dependency per dependency info
type Dependency struct {
depType int // golang, nodejs, python etc
path string // the module path, github.com/teris-io/shortid
version string // v0.0.0-20171029131806-771a37caa5cf
files []string // if available, list of all files for a package
DepType Bitmask // golang, nodejs, python etc
Path string // the module path, github.com/teris-io/shortid
Version string // v0.0.0-20171029131806-771a37caa5cf
Files []string // if available, list of all files for a package
// /usr/lib/go-1.13/src/regexp/syntax/compile.go
// /usr/lib/go-1.13/src/regexp/syntax/doc.go
}
Expand Down
14 changes: 7 additions & 7 deletions deplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ func GetDeps(fullPath string) ([]Dependency, Bitmask, error) {

for _, p := range pkgs {
d := Dependency{
depType: langGolang,
path: p.PkgPath,
files: p.GoFiles,
DepType: langGolang,
Path: p.PkgPath,
Files: p.GoFiles,
}
if p.Module != nil {
d.version = p.Module.Version
d.Version = p.Module.Version
}
deps = append(deps, d)
}
Expand All @@ -68,9 +68,9 @@ func GetDeps(fullPath string) ([]Dependency, Bitmask, error) {
splitIdx := strings.LastIndex(p, "@")

d := Dependency{
depType: langNodeJS,
path: p[:splitIdx],
version: p[splitIdx+1:],
DepType: langNodeJS,
Path: p[:splitIdx],
Version: p[splitIdx+1:],
}
deps = append(deps, d)
}
Expand Down
18 changes: 9 additions & 9 deletions deplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ func BuildWant() []Dependency {

for _, n := range golangPaths {
d := Dependency{
depType: 1,
path: n,
DepType: 1,
Path: n,
}

deps = append(deps, d)
}

end := len(deps) - 2 // get the unicode ver
deps[end].version = "v0.3.3"
deps[end].Version = "v0.3.3"

for _, n := range nodejsPaths {
d := Dependency{
depType: 2,
path: n,
DepType: 2,
Path: n,
}
deps = append(deps, d)
}
Expand All @@ -141,12 +141,12 @@ func TestGetDeps(t *testing.T) {
}

for i, pkg := range want {
if pkg.path != got[i].path {
t.Errorf("GetDeps() got %s; want %s", got[i].path, pkg.path)
if pkg.Path != got[i].Path {
t.Errorf("GetDeps() got %s; want %s", got[i].Path, pkg.Path)
}

if pkg.version != "" && pkg.version != got[i].version {
t.Errorf("GetDeps() got %s %s; want %s %s", got[i].path, got[i].version, pkg.path, pkg.version)
if pkg.Version != "" && pkg.Version != got[i].Version {
t.Errorf("GetDeps() got %s %s; want %s %s", got[i].Path, got[i].Version, pkg.Path, pkg.Version)
}
}
}

0 comments on commit 05bf80f

Please sign in to comment.