Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Kumar <[email protected]>
  • Loading branch information
AkashKumar7902 committed May 14, 2024
1 parent 1e5f228 commit bc62300
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/mvs/mvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion pkg/mvs/mvs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mvs
import (
"os"
"path/filepath"
"sort"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit bc62300

Please sign in to comment.