github.com/argoproj/argo-cd/v3@v3.2.1/util/helm/index_test.go (about)

     1  package helm
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  var index = Index{
    11  	Entries: map[string]Entries{
    12  		"argo-cd": {
    13  			{Version: "~0.7.3"},
    14  			{Version: "0.7.1"},
    15  			{Version: "0.5.4"},
    16  			{Version: "0.5.3"},
    17  			{Version: "0.7.2"},
    18  			{Version: "0.5.2"},
    19  			{Version: "~0.5.2"},
    20  			{Version: "0.5.1"},
    21  			{Version: "0.5.0"},
    22  		},
    23  	},
    24  }
    25  
    26  func TestIndex_GetEntries(t *testing.T) {
    27  	t.Run("NotFound", func(t *testing.T) {
    28  		_, err := index.GetEntries("foo")
    29  		require.EqualError(t, err, "chart 'foo' not found in index")
    30  	})
    31  	t.Run("Found", func(t *testing.T) {
    32  		ts, err := index.GetEntries("argo-cd")
    33  		require.NoError(t, err)
    34  		assert.Len(t, ts, len(index.Entries["argo-cd"]))
    35  	})
    36  }