diff --git a/cmd/argocd/commands/projectwindows.go b/cmd/argocd/commands/projectwindows.go index 239b9e2c85..87d5dfe1a5 100644 --- a/cmd/argocd/commands/projectwindows.go +++ b/cmd/argocd/commands/projectwindows.go @@ -362,7 +362,7 @@ argocd proj windows list test-project`, func printSyncWindows(proj *v1alpha1.AppProject) { w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) var fmtStr string - headers := []any{"ID", "STATUS", "KIND", "SCHEDULE", "DURATION", "APPLICATIONS", "NAMESPACES", "CLUSTERS", "MANUALSYNC", "TIMEZONE"} + headers := []any{"ID", "STATUS", "KIND", "SCHEDULE", "DURATION", "APPLICATIONS", "NAMESPACES", "CLUSTERS", "MANUALSYNC", "TIMEZONE", "USEANDOPERATOR"} fmtStr = strings.Repeat("%s\t", len(headers)) + "\n" fmt.Fprintf(w, fmtStr, headers...) if proj.Spec.SyncWindows.HasWindows() { diff --git a/cmd/argocd/commands/projectwindows_test.go b/cmd/argocd/commands/projectwindows_test.go new file mode 100644 index 0000000000..069dd49e6d --- /dev/null +++ b/cmd/argocd/commands/projectwindows_test.go @@ -0,0 +1,40 @@ +package commands + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1" +) + +func TestPrintSyncWindows(t *testing.T) { + proj := &v1alpha1.AppProject{ + ObjectMeta: metav1.ObjectMeta{Name: "test-project"}, + Spec: v1alpha1.AppProjectSpec{ + SyncWindows: v1alpha1.SyncWindows{ + { + Kind: "allow", + Schedule: "* * * * *", + Duration: "1h", + Applications: []string{"app1"}, + Namespaces: []string{"ns1"}, + Clusters: []string{"cluster1"}, + ManualSync: true, + UseAndOperator: true, + }, + }, + }, + } + + output, err := captureOutput(func() error { + printSyncWindows(proj) + return nil + }) + require.NoError(t, err) + t.Log(output) + assert.Contains(t, output, "ID STATUS KIND SCHEDULE DURATION APPLICATIONS NAMESPACES CLUSTERS MANUALSYNC TIMEZONE USEANDOPERATOR") + assert.Contains(t, output, "0 Active allow * * * * * 1h app1 ns1 cluster1 Enabled Enabled") +}