Skip to content

Commit

Permalink
Update test to only set CloudProvider on create
Browse files Browse the repository at this point in the history
* There was an upstream bug that was not persisting the CloudeProvider
  when included in the CreateBuild API body. Now that this fix is in
  place, calling the UpdateBuild with the 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
```
  • Loading branch information
nywilken committed Mar 2, 2022
1 parent f678fea commit d87efcb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/provider/data_source_packer_image_iteration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ func upsertBuild(t *testing.T, bucketSlug, fingerprint, iterationID string) {
updateBuildParams.BuildID = build.Payload.Build.ID
updateBuildParams.Body = &models.HashicorpCloudPackerUpdateBuildRequest{
Updates: &models.HashicorpCloudPackerBuildUpdates{
CloudProvider: "aws",
Status: models.HashicorpCloudPackerBuildStatusDONE,
Status: models.HashicorpCloudPackerBuildStatusDONE,
Images: []*models.HashicorpCloudPackerImageCreateBody{
{
ImageID: "ami-42",
Expand Down

0 comments on commit d87efcb

Please sign in to comment.