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

     1  package util
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	argoprojiov1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
     9  )
    10  
    11  var appSet = `apiVersion: argoproj.io/v1alpha1
    12  kind: ApplicationSet
    13  metadata:
    14    name: guestbook
    15  spec:
    16    generators:
    17    - list:
    18        elements:
    19        - cluster: engineering-dev
    20          url: https://1.2.3.4
    21    template:
    22      metadata:
    23        name: '{{cluster}}-guestbook'
    24      spec:
    25        source:
    26          repoURL: https://github.com/infra-team/cluster-deployments.git
    27          targetRevision: HEAD
    28          path: guestbook/{{cluster}}
    29        destination:
    30          server: '{{url}}'
    31          namespace: guestbook
    32  `
    33  
    34  func TestReadAppSet(t *testing.T) {
    35  	var appSets []*argoprojiov1alpha1.ApplicationSet
    36  	err := readAppset([]byte(appSet), &appSets)
    37  	if err != nil {
    38  		t.Logf("Failed reading appset file")
    39  	}
    40  	assert.Len(t, appSets, 1)
    41  }