MCPcopy
hub / github.com/kubernetes/kubectl / TestApplyFlagValidation

Function TestApplyFlagValidation

pkg/cmd/apply/apply_test.go:158–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestApplyFlagValidation(t *testing.T) {
159 tests := []struct {
160 args [][]string
161 enableAlphas []cmdutil.FeatureGate
162 expectedErr string
163 }{
164 {
165 args: [][]string{
166 {"force-conflicts", "true"},
167 },
168 expectedErr: "--force-conflicts only works with --server-side",
169 },
170 {
171 args: [][]string{
172 {"server-side", "true"},
173 {"dry-run", "client"},
174 },
175 expectedErr: "--dry-run=client doesn't work with --server-side (did you mean --dry-run=server instead?)",
176 },
177 {
178 args: [][]string{
179 {"force", "true"},
180 {"server-side", "true"},
181 },
182 expectedErr: "--force cannot be used with --server-side",
183 },
184 {
185 args: [][]string{
186 {"force", "true"},
187 {"dry-run", "server"},
188 },
189 expectedErr: "--dry-run=server cannot be used with --force",
190 },
191 {
192 args: [][]string{
193 {"all", "true"},
194 {"selector", "unused"},
195 },
196 expectedErr: "cannot set --all and --selector at the same time",
197 },
198 {
199 args: [][]string{
200 {"force", "true"},
201 {"prune", "true"},
202 {"all", "true"},
203 },
204 expectedErr: "--force cannot be used with --prune",
205 },
206 {
207 args: [][]string{
208 {"prune", "true"},
209 {"force", "true"},
210 {"applyset", "mySecret"},
211 {"namespace", "myNs"},
212 },
213 enableAlphas: []cmdutil.FeatureGate{cmdutil.ApplySet},
214 expectedErr: "--force cannot be used with --prune",
215 },

Callers

nothing calls this directly

Calls 8

CleanupMethod · 0.95
AddFlagsMethod · 0.95
WithNamespaceMethod · 0.95
ToOptionsMethod · 0.95
NewApplyFlagsFunction · 0.85
RunMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…