Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to only set CloudProvider on CreateBuild #260

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

nywilken
Copy link
Contributor

@nywilken nywilken commented Mar 2, 2022

There was an upstream bug that was not persisting the CloudeProvider when included in the CreateBuild API body. Now calling UpdateBuild with a CloudProvider returns an error; thus causing the tests to fail.

Tests Before Change

=== RUN   TestAcc_dataSourcePacker
    data_source_packer_image_iteration_test.go:298: unexpected UpdateBuild error, expected nil. Got [PATCH /packer/2021-04-30/organizations/{location.organization_id}/projects/{location.project_id}/builds/{build_id}][409] PackerService_UpdateBuild default  &{Code:6 Details:[] Error:You cannot override a build's Cloud Provider if it has already been set.  Message:You cannot override a build's Cloud Provider if it has already been set. }
    data_source_packer_image_iteration_test.go:466: unexpected CreateChannel error, expected nil. Got [POST /packer/2021-04-30/organizations/{location.organization_id}/projects/{location.project_id}/images/{bucket_slug}/channels][400] PackerService_CreateChannel default  &{Code:9 Details:[] Error:Error creating channel: iteration is incomplete. Message:Error creating channel: iteration is incomplete.}
    data_source_packer_image_iteration_test.go:443: Step 1/1 error: Error running pre-apply refresh: exit status 1

        Error: could not load the channel. something in the request is invalid.

          with data.hcp_packer_image_iteration.alpine,
          on terraform_plugin_test.tf line 4, in data "hcp_packer_image_iteration" "alpine":
           4: 	data "hcp_packer_image_iteration" "alpine" {

Tests After Change

testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/input	0.700s [no tests to run]
=== RUN   TestAcc_dataSourcePacker
--- PASS: TestAcc_dataSourcePacker (11.98s)
=== RUN   TestAcc_dataSourcePacker_revokedIteration
--- PASS: TestAcc_dataSourcePacker_revokedIteration (7.75s)
=== RUN   TestAcc_dataSourcePackerImage
--- PASS: TestAcc_dataSourcePackerImage (8.06s)
=== RUN   TestAcc_dataSourcePackerIteration
--- PASS: TestAcc_dataSourcePackerIteration (7.77s)
=== RUN   TestAcc_dataSourcePackerIteration_revokedIteration
--- PASS: TestAcc_dataSourcePackerIteration_revokedIteration (7.97s)
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/provider	43.926s

@nywilken nywilken requested a review from a team March 2, 2022 00:18
* There was an upstream bug that was not persisting the CloudeProvider
  when included in the CreateBuild API body. Now, with the fix in place,
  calling UpdateBuild with a CloudProvider set returns an
  error; thus causing the tests to fail.

Tests Before Change
```
=== RUN   TestAcc_dataSourcePacker
    data_source_packer_image_iteration_test.go:298: unexpected UpdateBuild error, expected nil. Got [PATCH /packer/2021-04-30/organizations/{location.organization_id}/projects/{location.project_id}/builds/{build_id}][409] PackerService_UpdateBuild default  &{Code:6 Details:[] Error:You cannot override a build's Cloud Provider if it has already been set.  Message:You cannot override a build's Cloud Provider if it has already been set. }
    data_source_packer_image_iteration_test.go:466: unexpected CreateChannel error, expected nil. Got [POST /packer/2021-04-30/organizations/{location.organization_id}/projects/{location.project_id}/images/{bucket_slug}/channels][400] PackerService_CreateChannel default  &{Code:9 Details:[] Error:Error creating channel: iteration is incomplete. Message:Error creating channel: iteration is incomplete.}
    data_source_packer_image_iteration_test.go:443: Step 1/1 error: Error running pre-apply refresh: exit status 1

        Error: could not load the channel. something in the request is invalid.

          with data.hcp_packer_image_iteration.alpine,
          on terraform_plugin_test.tf line 4, in data "hcp_packer_image_iteration" "alpine":
           4: 	data "hcp_packer_image_iteration" "alpine" {
```

Tests After Change
```
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/input	0.700s [no tests to run]
=== RUN   TestAcc_dataSourcePacker
--- PASS: TestAcc_dataSourcePacker (11.98s)
=== RUN   TestAcc_dataSourcePacker_revokedIteration
--- PASS: TestAcc_dataSourcePacker_revokedIteration (7.75s)
=== RUN   TestAcc_dataSourcePackerImage
--- PASS: TestAcc_dataSourcePackerImage (8.06s)
=== RUN   TestAcc_dataSourcePackerIteration
--- PASS: TestAcc_dataSourcePackerIteration (7.77s)
=== RUN   TestAcc_dataSourcePackerIteration_revokedIteration
--- PASS: TestAcc_dataSourcePackerIteration_revokedIteration (7.97s)
PASS
ok  	github.com/hashicorp/terraform-provider-hcp/internal/provider	43.926s
```
@nywilken nywilken force-pushed the fix/packer_datasource_acceptance_test branch from d87efcb to 19cdc91 Compare March 2, 2022 00:21
Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@nywilken nywilken changed the title Update test to only set CloudProvider on create Update tests to only set CloudProvider on CreateBuild Mar 2, 2022
@nywilken nywilken merged commit 4340845 into main Mar 2, 2022
@nywilken nywilken deleted the fix/packer_datasource_acceptance_test branch March 2, 2022 00:29
@nywilken
Copy link
Contributor Author

nywilken commented Mar 2, 2022

cc @sylviamoss for visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants