MCPcopy Create free account
hub / github.com/conforma/cli / TestRetryConfigurationFlags

Function TestRetryConfigurationFlags

cmd/root/root_cmd_test.go:82–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestRetryConfigurationFlags(t *testing.T) {
83 tests := []struct {
84 name string
85 args []string
86 expectedConfig http.RetryConfig
87 }{
88 {
89 name: "default retry configuration",
90 args: []string{},
91 expectedConfig: http.RetryConfig{
92 MaxWait: 3 * time.Second,
93 MaxRetry: 3,
94 Duration: 1 * time.Second,
95 Factor: 2.0,
96 Jitter: 0.1,
97 },
98 },
99 {
100 name: "custom retry configuration",
101 args: []string{
102 "--retry-max-wait", "2s",
103 "--retry-max-retry", "5",
104 "--retry-duration", "500ms",
105 "--retry-factor", "1.5",
106 "--retry-jitter", "0.2",
107 },
108 expectedConfig: http.RetryConfig{
109 MaxWait: 2 * time.Second,
110 MaxRetry: 5,
111 Duration: 500 * time.Millisecond,
112 Factor: 1.5,
113 Jitter: 0.2,
114 },
115 },
116 }
117
118 for _, tt := range tests {
119 t.Run(tt.name, func(t *testing.T) {
120 // Reset to default values
121 retryMaxWait = 3 * time.Second
122 retryMaxRetry = 3
123 retryDuration = 1 * time.Second
124 retryFactor = 2.0
125 retryJitter = 0.1
126
127 cmd := NewRootCmd()
128 if len(tt.args) > 0 {
129 cmd.SetArgs(append(tt.args, "version"))
130 } else {
131 cmd.SetArgs([]string{"version"})
132 }
133
134 // Execute the command to trigger flag parsing and configuration
135 err := cmd.Execute()
136 assert.NoError(t, err)
137
138 // Verify the configuration was applied by checking the actual values
139 // The configuration is applied in PersistentPreRun, so we need to check

Callers

nothing calls this directly

Calls 2

NewRootCmdFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected