argo-cd/reposerver/repository/chart_test.go
Michael Crenshaw 0ec46f6857
chore(ci): upgrade golangci-lint to v2 (#22484)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-27 12:37:52 -04:00

64 lines
1.3 KiB
Go

package repository
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_getChartDetailsNotSet(t *testing.T) {
chart1 := `apiVersion: v3
name: mychart
version: 0.0.0`
cd, err := getChartDetails(chart1)
require.NoError(t, err)
assert.Empty(t, cd.Description)
assert.Equal(t, cd.Maintainers, []string(nil))
assert.Empty(t, cd.Home)
}
func Test_getChartDetailsSet(t *testing.T) {
chart1 := `apiVersion: v3
name: mychart
version: 0.0.0
description: a good chart
home: https://example.com
maintainers:
- name: alex
email: example@example.com
`
cd, err := getChartDetails(chart1)
require.NoError(t, err)
assert.Equal(t, "a good chart", cd.Description)
assert.Equal(t, []string{"alex <example@example.com>"}, cd.Maintainers)
assert.Equal(t, "https://example.com", cd.Home)
chart1 = `apiVersion: v3
name: mychart
version: 0.0.0
description: a good chart
home: https://example.com
maintainers:
- name: alex
`
cd, err = getChartDetails(chart1)
require.NoError(t, err)
assert.Equal(t, []string{"alex"}, cd.Maintainers)
}
func Test_getChartDetailsBad(t *testing.T) {
chart1 := `apiVersion: v3
name: mychart
version: 0.0.0
description: a good chart
home: https://example.com
maintainers: alex
`
cd, err := getChartDetails(chart1)
require.Error(t, err)
assert.Nil(t, cd)
}