Skip to content
712 changes: 181 additions & 531 deletions reposerver/repository/repository.go

Large diffs are not rendered by default.

24 changes: 3 additions & 21 deletions reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/argoproj/argo-cd/v3/util/oci"

cacheutil "github.com/argoproj/argo-cd/v3/util/cache"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -126,13 +124,13 @@ func newServiceWithMocks(t *testing.T, root string, signed bool) (*Service, *git
chart := "my-chart"
oobChart := "out-of-bounds-chart"
version := "1.1.0"
helmClient.EXPECT().GetIndex(mock.AnythingOfType("bool"), mock.Anything).Return(&helm.Index{Entries: map[string]helm.Entries{
helmClient.EXPECT().GetIndex(mock.AnythingOfType("bool")).Return(&helm.Index{Entries: map[string]helm.Entries{
chart: {{Version: "1.0.0"}, {Version: version}},
oobChart: {{Version: "1.0.0"}, {Version: version}},
}}, nil)
helmClient.EXPECT().GetTags(mock.Anything, mock.Anything).Return(nil, nil)
helmClient.EXPECT().ExtractChart(chart, version, false, int64(0), false).Return("./testdata/my-chart", utilio.NopCloser, nil)
helmClient.EXPECT().ExtractChart(oobChart, version, false, int64(0), false).Return("./testdata2/out-of-bounds-chart", utilio.NopCloser, nil)
helmClient.EXPECT().ExtractChart(chart, version).Return("./testdata/my-chart", utilio.NopCloser, nil)
helmClient.EXPECT().ExtractChart(oobChart, version).Return("./testdata2/out-of-bounds-chart", utilio.NopCloser, nil)
helmClient.EXPECT().CleanChartCache(chart, version).Return(nil)
helmClient.EXPECT().CleanChartCache(oobChart, version).Return(nil)

Expand Down Expand Up @@ -164,9 +162,6 @@ func newServiceWithOpt(t *testing.T, cf clientFunc, root string) (*Service, *git
service.newHelmClient = func(_ string, _ helm.Creds, _ bool, _ string, _ string, _ ...helm.ClientOpts) helm.Client {
return helmClient
}
service.newOCIClient = func(_ string, _ oci.Creds, _ string, _ string, _ []string, _ ...oci.ClientOpts) (oci.Client, error) {
return ociClient, nil
}
service.gitRepoInitializer = func(_ string) goio.Closer {
return utilio.NopCloser
}
Expand Down Expand Up @@ -1941,19 +1936,6 @@ func Test_newEnv(t *testing.T) {
}, "my-revision"))
}

func TestService_newHelmClientResolveRevision(t *testing.T) {
service := newService(t, ".")

t.Run("EmptyRevision", func(t *testing.T) {
_, _, err := service.newHelmClientResolveRevision(&v1alpha1.Repository{}, "", "my-chart", true)
assert.EqualError(t, err, "invalid revision: failed to determine semver constraint: improper constraint: ")
})
t.Run("InvalidRevision", func(t *testing.T) {
_, _, err := service.newHelmClientResolveRevision(&v1alpha1.Repository{}, "???", "my-chart", true)
assert.EqualError(t, err, "invalid revision: failed to determine semver constraint: improper constraint: ???")
})
}

func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
t.Run("No app name set and app specific file exists", func(t *testing.T) {
service := newService(t, ".")
Expand Down
Loading
Loading