mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
Every command is cd-*: cd, cd-server, cd-repo-server, cd-application-controller, cd-applicationset-controller, cd-cmp-server, cd-commit-server, cd-dex, cd-git-ask-pass, cd-k8s-auth, cd-notification. util/argo is util/cd; util/notification/argocd is util/notification/cd. Preserved deliberately: github.com/argoproj/argocd-example-apps is an EXTERNAL repo used as an e2e fixture, and notifications-engine + pkg/v2 are real dependencies. Renaming a URL we do not own would break the tests. Two bugs I made and caught, both from a careless sed: - s/argo/cd/g turned 'argocd' into 'cdcd' in two directory names - renaming the package declaration left every call site saying argo.X go build ./... exit 0. Co-authored-by: Hanzo Dev <[email protected]>
58 lines
2.3 KiB
Go
58 lines
2.3 KiB
Go
package commands
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestNewCommand_HydrationProcessorsFlag pins down the contract for the manifest hydration concurrency
|
|
// knob added for https://github.com/argoproj/argo-cd/issues/27926: the flag exists and defaults to a value
|
|
// greater than 1 (so the default deployment exercises hydration concurrency and tests are more likely to
|
|
// catch races, per the maintainer's guidance on the issue).
|
|
func TestNewCommand_HydrationProcessorsFlag(t *testing.T) {
|
|
cmd := NewCommand()
|
|
|
|
f := cmd.Flags().Lookup("hydration-processors")
|
|
require.NotNil(t, f, "expected --hydration-processors flag to be registered")
|
|
assert.Equal(t, "5", f.DefValue, "default hydration processors should be greater than 1")
|
|
}
|
|
|
|
// TestNewCommand_MetricsFlagsFromEnv verifies the metrics label/condition flags
|
|
// default from their environment variables, so they can be configured through
|
|
// cd-cmd-params-cm like the other controller parameters.
|
|
func TestNewCommand_MetricsFlagsFromEnv(t *testing.T) {
|
|
t.Setenv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_LABELS", "team,env")
|
|
t.Setenv("CD_APPLICATION_CONTROLLER_METRICS_APPLICATION_CONDITIONS", "OrphanedResourceWarning")
|
|
t.Setenv("CD_APPLICATION_CONTROLLER_METRICS_CLUSTER_LABELS", "environment")
|
|
|
|
cmd := NewCommand()
|
|
|
|
labels, err := cmd.Flags().GetStringSlice("metrics-application-labels")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []string{"team", "env"}, labels)
|
|
|
|
conditions, err := cmd.Flags().GetStringSlice("metrics-application-conditions")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []string{"OrphanedResourceWarning"}, conditions)
|
|
|
|
clusterLabels, err := cmd.Flags().GetStringSlice("metrics-cluster-labels")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []string{"environment"}, clusterLabels)
|
|
}
|
|
|
|
func TestNewCommand_MetricsFlagHelpUsesActualMetricNames(t *testing.T) {
|
|
cmd := NewCommand()
|
|
|
|
labelsFlag := cmd.Flags().Lookup("metrics-application-labels")
|
|
require.NotNil(t, labelsFlag)
|
|
assert.Contains(t, labelsFlag.Usage, "cd_app_labels")
|
|
assert.NotContains(t, labelsFlag.Usage, "cd_application_labels")
|
|
|
|
conditionsFlag := cmd.Flags().Lookup("metrics-application-conditions")
|
|
require.NotNil(t, conditionsFlag)
|
|
assert.Contains(t, conditionsFlag.Usage, "cd_app_condition")
|
|
assert.NotContains(t, conditionsFlag.Usage, "cd_application_conditions")
|
|
}
|