github.com/verrazzano/verrazzano@v1.7.0/tools/charts-manager/vcm/cmd/pull/pull_test.go (about) 1 // Copyright (c) 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package pull 5 6 import ( 7 "fmt" 8 "strconv" 9 "testing" 10 11 "github.com/stretchr/testify/assert" 12 "github.com/verrazzano/verrazzano/tools/charts-manager/vcm/cmd/helpers" 13 "github.com/verrazzano/verrazzano/tools/charts-manager/vcm/pkg/constants" 14 "github.com/verrazzano/verrazzano/tools/charts-manager/vcm/pkg/helm" 15 "github.com/verrazzano/verrazzano/tools/charts-manager/vcm/tests/pkg/fakes" 16 vcmtesthelpers "github.com/verrazzano/verrazzano/tools/charts-manager/vcm/tests/pkg/helpers" 17 vzhelpers "github.com/verrazzano/verrazzano/tools/vz/pkg/helpers" 18 ) 19 20 // TestNewCmdPull tests that function NewCmdPull creates pull cmd with correct flags 21 // GIVEN a call to NewCmdPull 22 // 23 // WHEN correct arguments are passed 24 // THEN the pull cmd instance created contains all the required flags. 25 func TestNewCmdPull(t *testing.T) { 26 rc, cleanup, err := vcmtesthelpers.ContextSetup() 27 assert.NoError(t, err) 28 defer cleanup() 29 cmd := NewCmdPull(rc, fakes.FakeHelmChartFileSystem{}, fakes.FakeHelmConfig{}) 30 assert.NotNil(t, cmd, "command is nil") 31 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagChartName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagChartName)) 32 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagVersionName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagVersionName)) 33 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagRepoName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagRepoName)) 34 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagDirName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagDirName)) 35 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagTargetVersionName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagTargetVersionName)) 36 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagUpstreamProvenanceName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagUpstreamProvenanceName)) 37 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagPatchName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagPatchName)) 38 assert.NotNil(t, cmd.PersistentFlags().Lookup(constants.FlagPatchVersionName), fmt.Sprintf(vcmtesthelpers.FlagNotFound, constants.FlagPatchVersionName)) 39 assert.Equal(t, buildExample(), cmd.Example) 40 } 41 42 // TestExecPullCmd tests the execution of pull command 43 // GIVEN a call to NewCmdPull and then executing the resulting pull command with specific parameters to pull a chart 44 // 45 // WHEN invalid arguments are passed 46 // THEN the cmd execution results in an error. 47 // 48 // WHEN adding/updating helm repo results in an error 49 // THEN the cmd execution results in an error. 50 // 51 // WHEN downloading helm chart results in an error 52 // THEN the cmd execution results in an error. 53 // 54 // WHEN rearranging the chart directory results in an error 55 // THEN the cmd execution results in an error. 56 // 57 // WHEN the chart is downloaded to correct directory and no upstream was to be saved 58 // AND no patching from a previous version is to be applied 59 // THEN the cmd execution does not result in an error. 60 // 61 // WHEN saving upstream chart returns in error 62 // THEN the cmd execution results in an error. 63 // 64 // WHEN saving upstream chart returns in error 65 // THEN the cmd execution results in an error. 66 // 67 // WHEN creating the chart provenance data returns in error 68 // THEN the cmd execution results in an error. 69 // 70 // WHEN saving the chart provenance file returns in error 71 // THEN the cmd execution results in an error. 72 // 73 // WHEN saving upstream chart is successful and chart provenance is saved and patch flag is false 74 // THEN the cmd execution results in no error. 75 // 76 // WHEN patch flag is true and finding the version to generate the patch from is unsuccessful 77 // THEN the cmd execution results in an error. 78 // 79 // WHEN patch flag is true and generting the patch is unsuccessful 80 // THEN the cmd execution results in an error. 81 // 82 // WHEN patch flag is true and no patch file is generated because there are no diffs 83 // THEN the cmd execution results in no error. 84 // 85 // WHEN patch flag is true and patch file is generated but applying the patch is unsuccessful 86 // THEN the cmd execution results in error. 87 // 88 // WHEN patch flag is true and a rejects file is generated while applying the patch 89 // THEN the cmd execution results in error. 90 func TestExecPullCmd(t *testing.T) { 91 rc, cleanup, err := vcmtesthelpers.ContextSetup() 92 assert.NoError(t, err) 93 defer cleanup() 94 type args struct { 95 chart string 96 version string 97 chartsDir string 98 repo string 99 targetVersion string 100 upstreamProv bool 101 patch bool 102 patchVersion string 103 } 104 tests := []struct { 105 name string 106 args args 107 hfs fakes.FakeHelmChartFileSystem 108 helmConfig fakes.FakeHelmConfig 109 wantError error 110 }{ 111 { 112 name: "testChartArgumentNilThrowsError", 113 args: args{chart: "", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 114 hfs: fakes.FakeHelmChartFileSystem{}, 115 wantError: fmt.Errorf(helpers.ErrFormatMustSpecifyFlag, constants.FlagChartName, constants.FlagChartName, constants.FlagChartShorthand), 116 }, 117 { 118 name: "testChartArgumentEmptyThrowsError", 119 args: args{chart: "\n", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 120 hfs: fakes.FakeHelmChartFileSystem{}, 121 wantError: fmt.Errorf(helpers.ErrFormatNotEmpty, constants.FlagChartName), 122 }, 123 { 124 name: "testVersionArgumentNilThrowsError", 125 args: args{chart: "chart", version: "", chartsDir: "/tmp/charts", repo: "https://test"}, 126 hfs: fakes.FakeHelmChartFileSystem{}, 127 wantError: fmt.Errorf(helpers.ErrFormatMustSpecifyFlag, constants.FlagVersionName, constants.FlagVersionName, constants.FlagVersionShorthand), 128 }, 129 { 130 name: "testVersionArgumentEmptyThrowsError", 131 args: args{chart: "chart", version: "\t", chartsDir: "/tmp/charts", repo: "https://test"}, 132 hfs: fakes.FakeHelmChartFileSystem{}, 133 wantError: fmt.Errorf(helpers.ErrFormatNotEmpty, constants.FlagVersionName), 134 }, 135 { 136 name: "testRepoArgumentNilThrowsError", 137 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: ""}, 138 hfs: fakes.FakeHelmChartFileSystem{}, 139 wantError: fmt.Errorf(helpers.ErrFormatMustSpecifyFlag, constants.FlagRepoName, constants.FlagRepoName, constants.FlagRepoShorthand), 140 }, 141 { 142 name: "testRepoArgumentEmptyThrowsError", 143 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "\n\t"}, 144 hfs: fakes.FakeHelmChartFileSystem{}, 145 wantError: fmt.Errorf(helpers.ErrFormatNotEmpty, constants.FlagRepoName), 146 }, 147 { 148 name: "testDirArgumentNilThrowsError", 149 args: args{chart: "chart", version: "0.0.1", chartsDir: "", repo: "https://test"}, 150 hfs: fakes.FakeHelmChartFileSystem{}, 151 wantError: fmt.Errorf(helpers.ErrFormatMustSpecifyFlag, constants.FlagDirName, constants.FlagDirName, constants.FlagDirShorthand), 152 }, 153 { 154 name: "testDirArgumentEmptyThrowsError", 155 args: args{chart: "chart", version: "0.0.1", chartsDir: "\n", repo: "https://test"}, 156 hfs: fakes.FakeHelmChartFileSystem{}, 157 wantError: fmt.Errorf(helpers.ErrFormatNotEmpty, constants.FlagDirName), 158 }, 159 { 160 name: "testAddAndUpdateChartRepoThrowsError", 161 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 162 helmConfig: fakes.FakeHelmConfig{ 163 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 164 return "", fmt.Errorf(vcmtesthelpers.DummyError) 165 }, 166 }, 167 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 168 }, 169 { 170 name: "testDownloadChartThrowsError", 171 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 172 helmConfig: fakes.FakeHelmConfig{ 173 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 174 return "", nil 175 }, 176 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 177 return fmt.Errorf(vcmtesthelpers.DummyError) 178 }, 179 }, 180 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 181 }, 182 { 183 name: "testRearrangeChartDirectoryThrowsError", 184 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 185 helmConfig: fakes.FakeHelmConfig{ 186 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 187 return "", nil 188 }, 189 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 190 return nil 191 }, 192 }, 193 hfs: fakes.FakeHelmChartFileSystem{ 194 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 195 return fmt.Errorf(vcmtesthelpers.DummyError) 196 }, 197 }, 198 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 199 }, 200 { 201 name: "testNoSaveUpstreamNoDiffThrowsNoError", 202 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test"}, 203 helmConfig: fakes.FakeHelmConfig{ 204 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 205 return "", nil 206 }, 207 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 208 return nil 209 }, 210 }, 211 hfs: fakes.FakeHelmChartFileSystem{ 212 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 213 return nil 214 }, 215 }, 216 wantError: nil, 217 }, 218 { 219 name: "testSaveUpstreamThrowsError", 220 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true}, 221 helmConfig: fakes.FakeHelmConfig{ 222 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 223 return "", nil 224 }, 225 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 226 return nil 227 }, 228 }, 229 hfs: fakes.FakeHelmChartFileSystem{ 230 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 231 return nil 232 }, 233 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 234 return fmt.Errorf(vcmtesthelpers.DummyError) 235 }, 236 }, 237 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 238 }, 239 { 240 name: "testGetChartProvenanceThrowsError", 241 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true}, 242 helmConfig: fakes.FakeHelmConfig{ 243 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 244 return "", nil 245 }, 246 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 247 return nil 248 }, 249 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 250 return nil, fmt.Errorf(vcmtesthelpers.DummyError) 251 }, 252 }, 253 hfs: fakes.FakeHelmChartFileSystem{ 254 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 255 return nil 256 }, 257 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 258 return nil 259 }, 260 }, 261 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 262 }, 263 { 264 name: "testSaveChartProvenanceThrowsError", 265 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true}, 266 helmConfig: fakes.FakeHelmConfig{ 267 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 268 return "", nil 269 }, 270 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 271 return nil 272 }, 273 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 274 return nil, nil 275 }, 276 }, 277 hfs: fakes.FakeHelmChartFileSystem{ 278 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 279 return nil 280 }, 281 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 282 return nil 283 }, 284 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 285 return fmt.Errorf(vcmtesthelpers.DummyError) 286 }, 287 }, 288 wantError: fmt.Errorf(vcmtesthelpers.DummyError), 289 }, 290 { 291 name: "testNoPatchDiffThrowsNoError", 292 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true}, 293 helmConfig: fakes.FakeHelmConfig{ 294 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 295 return "", nil 296 }, 297 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 298 return nil 299 }, 300 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 301 return nil, nil 302 }, 303 }, 304 hfs: fakes.FakeHelmChartFileSystem{ 305 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 306 return nil 307 }, 308 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 309 return nil 310 }, 311 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 312 return nil 313 }, 314 }, 315 wantError: nil, 316 }, 317 { 318 name: "testFindChartVersionToPatchThrowsError", 319 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true, patch: true}, 320 helmConfig: fakes.FakeHelmConfig{ 321 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 322 return "", nil 323 }, 324 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 325 return nil 326 }, 327 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 328 return nil, nil 329 }, 330 }, 331 hfs: fakes.FakeHelmChartFileSystem{ 332 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 333 return nil 334 }, 335 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 336 return nil 337 }, 338 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 339 return nil 340 }, 341 FakeFindChartVersionToPatch: func(chartsDir string, chart string, version string) (string, error) { 342 return "", fmt.Errorf(vcmtesthelpers.DummyError) 343 }, 344 }, 345 wantError: fmt.Errorf(ErrPatchVersionNotFound, fmt.Errorf(vcmtesthelpers.DummyError)), 346 }, 347 { 348 name: "testGeneratePatchFileThrowsError", 349 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true, patch: true, patchVersion: "x.y.z"}, 350 helmConfig: fakes.FakeHelmConfig{ 351 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 352 return "", nil 353 }, 354 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 355 return nil 356 }, 357 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 358 return nil, nil 359 }, 360 }, 361 hfs: fakes.FakeHelmChartFileSystem{ 362 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 363 return nil 364 }, 365 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 366 return nil 367 }, 368 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 369 return nil 370 }, 371 FakeGeneratePatchFile: func(chartsDir string, chart string, version string) (string, error) { 372 return "", fmt.Errorf(vcmtesthelpers.DummyError) 373 }, 374 }, 375 wantError: fmt.Errorf(ErrPatchNotGenerated, fmt.Errorf(vcmtesthelpers.DummyError)), 376 }, 377 { 378 name: "testNoPatchFileGeneratedNoError", 379 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true, patch: true, patchVersion: "x.y.z"}, 380 helmConfig: fakes.FakeHelmConfig{ 381 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 382 return "", nil 383 }, 384 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 385 return nil 386 }, 387 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 388 return nil, nil 389 }, 390 }, 391 hfs: fakes.FakeHelmChartFileSystem{ 392 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 393 return nil 394 }, 395 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 396 return nil 397 }, 398 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 399 return nil 400 }, 401 FakeGeneratePatchFile: func(chartsDir string, chart string, version string) (string, error) { 402 return "", nil 403 }, 404 }, 405 wantError: nil, 406 }, 407 { 408 name: "testApplyPatchFileThrowsError", 409 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true, patch: true, patchVersion: "x.y.z"}, 410 helmConfig: fakes.FakeHelmConfig{ 411 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 412 return "", nil 413 }, 414 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 415 return nil 416 }, 417 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 418 return nil, nil 419 }, 420 }, 421 hfs: fakes.FakeHelmChartFileSystem{ 422 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 423 return nil 424 }, 425 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 426 return nil 427 }, 428 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 429 return nil 430 }, 431 FakeGeneratePatchFile: func(chartsDir string, chart string, version string) (string, error) { 432 return "dummyfile", nil 433 }, 434 FakeApplyPatchFile: func(chartsDir string, vzHelper vzhelpers.VZHelper, chart string, version string, patchFile string) (bool, error) { 435 return false, fmt.Errorf(vcmtesthelpers.DummyError) 436 }, 437 }, 438 wantError: fmt.Errorf(ErrPatchNotApplied, "dummyfile", fmt.Errorf(vcmtesthelpers.DummyError)), 439 }, 440 { 441 name: "testRejectsFileGeneratedThrowsError", 442 args: args{chart: "chart", version: "0.0.1", chartsDir: "/tmp/charts", repo: "https://test", upstreamProv: true, patch: true, patchVersion: "x.y.z"}, 443 helmConfig: fakes.FakeHelmConfig{ 444 FakeAddAndUpdateChartRepo: func(chart string, repoUrl string) (string, error) { 445 return "", nil 446 }, 447 FakeDownloadChart: func(chart string, repo string, version string, targetVersion string, chartDir string) error { 448 return nil 449 }, 450 FakeGetChartProvenance: func(chart string, repo string, version string) (*helm.ChartProvenance, error) { 451 return nil, nil 452 }, 453 }, 454 hfs: fakes.FakeHelmChartFileSystem{ 455 FakeRearrangeChartDirectory: func(chartsDir string, chart string, targetVersion string) error { 456 return nil 457 }, 458 FakeSaveUpstreamChart: func(chartsDir string, chart string, version string, targetVersion string) error { 459 return nil 460 }, 461 FakeSaveChartProvenance: func(chartsDir string, chartProvenance *helm.ChartProvenance, chart string, targetVersion string) error { 462 return nil 463 }, 464 FakeGeneratePatchFile: func(chartsDir string, chart string, version string) (string, error) { 465 return "dummyfile", nil 466 }, 467 FakeApplyPatchFile: func(chartsDir string, vzHelper vzhelpers.VZHelper, chart string, version string, patchFile string) (bool, error) { 468 return true, nil 469 }, 470 }, 471 wantError: fmt.Errorf(ErrPatchReview, "dummyfile"), 472 }, 473 } 474 for _, tt := range tests { 475 t.Run(tt.name, func(t *testing.T) { 476 cmd := NewCmdPull(rc, tt.hfs, tt.helmConfig) 477 cmd.PersistentFlags().Set(constants.FlagChartName, tt.args.chart) 478 cmd.PersistentFlags().Set(constants.FlagVersionName, tt.args.version) 479 cmd.PersistentFlags().Set(constants.FlagDirName, tt.args.chartsDir) 480 cmd.PersistentFlags().Set(constants.FlagRepoName, tt.args.repo) 481 cmd.PersistentFlags().Set(constants.FlagPatchFileName, tt.args.targetVersion) 482 cmd.PersistentFlags().Lookup(constants.FlagUpstreamProvenanceName).Value.Set(strconv.FormatBool(tt.args.upstreamProv)) 483 cmd.PersistentFlags().Lookup(constants.FlagPatchName).Value.Set(strconv.FormatBool(tt.args.patch)) 484 cmd.PersistentFlags().Set(constants.FlagPatchVersionName, tt.args.patchVersion) 485 err := cmd.Execute() 486 if err != nil && tt.wantError == nil { 487 t.Errorf("pull exec with args %v resulted in error %v", tt.args, err) 488 } 489 490 if err != nil && tt.wantError != nil && err.Error() != tt.wantError.Error() { 491 t.Errorf("pull exec with args %v resulted in error %v, expected %v", tt.args, err, tt.wantError) 492 } 493 494 if err == nil && tt.wantError != nil { 495 t.Errorf("pull exec with args %v resulted in no error, expected %v", tt.args, tt.wantError) 496 } 497 }) 498 } 499 }