Files
deploy/util/app/discovery/discovery_test.go
2025-03-10 10:14:41 -04:00

52 lines
1.7 KiB
Go

package discovery
import (
"testing"
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDiscover(t *testing.T) {
apps, err := Discover(t.Context(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, map[string]string{
"foo": "Kustomize",
"baz": "Helm",
}, apps)
}
func TestAppType(t *testing.T) {
appType, err := AppType(t.Context(), "./testdata/foo", "./testdata", map[string]bool{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Kustomize", appType)
appType, err = AppType(t.Context(), "./testdata/baz", "./testdata", map[string]bool{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Helm", appType)
appType, err = AppType(t.Context(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)
}
func TestAppType_Disabled(t *testing.T) {
enableManifestGeneration := map[string]bool{
string(v1alpha1.ApplicationSourceTypeKustomize): false,
string(v1alpha1.ApplicationSourceTypeHelm): false,
}
appType, err := AppType(t.Context(), "./testdata/foo", "./testdata", enableManifestGeneration, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)
appType, err = AppType(t.Context(), "./testdata/baz", "./testdata", enableManifestGeneration, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)
appType, err = AppType(t.Context(), "./testdata", "./testdata", enableManifestGeneration, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)
}