github.com/argoproj/argo-cd/v3@v3.2.1/reposerver/repository/chart_test.go (about) 1 package repository 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func Test_getChartDetailsNotSet(t *testing.T) { 11 chart1 := `apiVersion: v3 12 name: mychart 13 version: 0.0.0` 14 15 cd, err := getChartDetails(chart1) 16 require.NoError(t, err) 17 assert.Empty(t, cd.Description) 18 assert.Equal(t, cd.Maintainers, []string(nil)) 19 assert.Empty(t, cd.Home) 20 } 21 22 func Test_getChartDetailsSet(t *testing.T) { 23 chart1 := `apiVersion: v3 24 name: mychart 25 version: 0.0.0 26 description: a good chart 27 home: https://example.com 28 maintainers: 29 - name: alex 30 email: example@example.com 31 ` 32 33 cd, err := getChartDetails(chart1) 34 require.NoError(t, err) 35 assert.Equal(t, "a good chart", cd.Description) 36 assert.Equal(t, []string{"alex <example@example.com>"}, cd.Maintainers) 37 assert.Equal(t, "https://example.com", cd.Home) 38 39 chart1 = `apiVersion: v3 40 name: mychart 41 version: 0.0.0 42 description: a good chart 43 home: https://example.com 44 maintainers: 45 - name: alex 46 ` 47 cd, err = getChartDetails(chart1) 48 require.NoError(t, err) 49 assert.Equal(t, []string{"alex"}, cd.Maintainers) 50 } 51 52 func Test_getChartDetailsBad(t *testing.T) { 53 chart1 := `apiVersion: v3 54 name: mychart 55 version: 0.0.0 56 description: a good chart 57 home: https://example.com 58 maintainers: alex 59 ` 60 61 cd, err := getChartDetails(chart1) 62 require.Error(t, err) 63 assert.Nil(t, cd) 64 }