Skip to content

Commit f1c5b3b

Browse files
committed
removing unnecessary function
1 parent 9b6c149 commit f1c5b3b

File tree

2 files changed

+0
-49
lines changed

2 files changed

+0
-49
lines changed

pkg/lifecycle/parser.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package lifecycle
33
import (
44
"context"
55
"fmt"
6-
"sort"
76
"strings"
87

9-
"github.com/Masterminds/semver"
108
"github.com/go-git/go-billy/v5"
119
helmRepo "helm.sh/helm/v3/pkg/repo"
1210
)
@@ -103,19 +101,3 @@ func (ld *Dependencies) populateAssetsVersionsPath(ctx context.Context) error {
103101
// Now fileNames slice contains the names of all files in the directories
104102
return nil
105103
}
106-
107-
// sortAssetsVersions will convert to semver and
108-
// sort the assets for each key in the assetsVersionsMap
109-
func (ld *Dependencies) sortAssetsVersions() {
110-
// Iterate over the map and sort the assets for each key
111-
for k, assets := range ld.AssetsVersionsMap {
112-
sort.Slice(assets, func(i, j int) bool {
113-
vi, _ := semver.NewVersion(assets[i].Version)
114-
vj, _ := semver.NewVersion(assets[j].Version)
115-
return vi.LessThan(vj)
116-
})
117-
ld.AssetsVersionsMap[k] = assets
118-
}
119-
120-
return
121-
}

pkg/lifecycle/parser_test.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -106,34 +106,3 @@ func Test_populateAssetsVersionsPath(t *testing.T) {
106106
assert.Error(t, err, "populateAssetsVersionsPath should have returned an error")
107107
})
108108
}
109-
110-
func Test_sortAssetsVersions(t *testing.T) {
111-
// Arrange
112-
dependency := &Dependencies{
113-
AssetsVersionsMap: map[string][]Asset{
114-
"chart1": {
115-
{Version: "1.0.0"},
116-
{Version: "0.1.0"},
117-
{Version: "0.0.1"},
118-
},
119-
"chart2": {
120-
{Version: "2.0.0"},
121-
{Version: "1.1.0"},
122-
{Version: "1.0.1"},
123-
},
124-
},
125-
}
126-
127-
// Act
128-
dependency.sortAssetsVersions()
129-
130-
// Assertions
131-
assert.Equal(t, len(dependency.AssetsVersionsMap), 2, "Expected 2 charts in the assetsVersionsMap")
132-
assert.Equal(t, dependency.AssetsVersionsMap["chart1"][0].Version, "0.0.1", "Expected 0.0.1")
133-
assert.Equal(t, dependency.AssetsVersionsMap["chart1"][1].Version, "0.1.0", "Expected 0.1.0")
134-
assert.Equal(t, dependency.AssetsVersionsMap["chart1"][2].Version, "1.0.0", "Expected 1.0.0")
135-
136-
assert.Equal(t, dependency.AssetsVersionsMap["chart2"][0].Version, "1.0.1", "Expected 1.0.1")
137-
assert.Equal(t, dependency.AssetsVersionsMap["chart2"][1].Version, "1.1.0", "Expected 1.1.0")
138-
assert.Equal(t, dependency.AssetsVersionsMap["chart2"][2].Version, "2.0.0", "Expected 2.0.0")
139-
}

0 commit comments

Comments
 (0)