diff --git a/pkg/mvs/mvs.go b/pkg/mvs/mvs.go index 0babc1ec..ea53475f 100644 --- a/pkg/mvs/mvs.go +++ b/pkg/mvs/mvs.go @@ -22,6 +22,12 @@ type ReqsGraph struct { } func (r ReqsGraph) Max(path, v1, v2 string) string { + if v1 == "none" || v2 == "" { + return v2 + } + if v2 == "none" || v1 == "" { + return v1 + } version1, err := version.NewVersion(v1) if err != nil { reporter.Fatal(reporter.FailedParseVersion, err, fmt.Sprintf("failed to parse version %s for module %s", v1, path)) diff --git a/pkg/mvs/mvs_test.go b/pkg/mvs/mvs_test.go index f18f3973..b90da6d5 100644 --- a/pkg/mvs/mvs_test.go +++ b/pkg/mvs/mvs_test.go @@ -3,6 +3,7 @@ package mvs import ( "os" "path/filepath" + "sort" "testing" "github.com/stretchr/testify/assert" @@ -52,9 +53,12 @@ func TestRequired(t *testing.T) { assert.Equal(t, len(req), 2) expectedReqs := []module.Version{ - {Path:"ccc", Version:"0.0.1"}, {Path:"bbb", Version:"0.0.1"}, + {Path:"ccc", Version:"0.0.1"}, } + sort.Slice(req, func(i, j int) bool { + return req[i].Path < req[j].Path + }) assert.Equal(t, req, expectedReqs) }