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

fix: send an empty array for IP ranges instead of null #516

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

ctreatma
Copy link
Contributor

@ctreatma ctreatma commented Jan 11, 2024

Fix #515.

The TestAccMetalVRF_withIPRanges started failing recently with an error that ip_ranges cannot be null. It appears this test failure was caused by #509, which consolidated the expandListToStringList and IfArrToStringArr functions.

This updates the IfArrToStringArr converter to match the old expandListToStringList implementation, which fixes the failing test.

@ctreatma
Copy link
Contributor Author

ctreatma commented Jan 11, 2024

FWIW, I don't really get why this implementation change is needed.

Near as I can tell, this was the line that was leading to test failure: https://github.com/equinix/terraform-provider-equinix/blob/main/equinix/resource_metal_vrf.go#L107

...but it seems like &ipRanges should have been non-nil in both cases based on this: https://go.dev/play/p/8vXQ6PWFi0Q

What am I missing?

More comprehensive Go sample courtesy of @displague: https://go.dev/play/p/aEANmMgMV0A

In most situations a nil slice and an empty slice are functionally equivalent, but JSON serialization is one situation where they are not functionally equivalent.

@ctreatma
Copy link
Contributor Author

Test passing again in CI: https://github.com/equinix/terraform-provider-equinix/actions/runs/7493501381/job/20399350107#step:5:500

@ctreatma ctreatma requested a deployment to internal January 11, 2024 21:37 — with GitHub Actions Abandoned
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2024

Codecov Report

Attention: 700 lines in your changes are missing coverage. Please review.

Comparison is base (26b2f3d) 60.11% compared to head (b9136db) 59.11%.
Report is 128 commits behind head on main.

Files Patch % Lines
internal/errors/errors.go 7.58% 134 Missing ⚠️
equinix/fabric_mapping_helper.go 0.00% 69 Missing ⚠️
equinix/resource_fabric_connection.go 0.00% 53 Missing ⚠️
equinix/resource_fabric_cloud_router.go 0.00% 43 Missing ⚠️
equinix/resource_network_device.go 2.50% 39 Missing ⚠️
equinix/resource_fabric_service_profile.go 0.00% 26 Missing ⚠️
internal/resources/metal/metal_ssh_key/resource.go 73.62% 19 Missing and 5 partials ⚠️
equinix/resource_fabric_routing_protocol.go 0.00% 23 Missing ⚠️
equinix/resource_metal_device.go 74.71% 18 Missing and 4 partials ⚠️
equinix/resource_metal_virtual_circuit.go 50.00% 13 Missing and 2 partials ⚠️
... and 43 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
- Coverage   60.11%   59.11%   -1.01%     
==========================================
  Files          99       96       -3     
  Lines       20045    19842     -203     
==========================================
- Hits        12051    11729     -322     
- Misses       7691     7822     +131     
+ Partials      303      291      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ctreatma
Copy link
Contributor Author

ctreatma commented Jan 11, 2024

The IfArrToStringArr function was introduced in #473; I looked through that PR and (1) the only things that were using that function prior to #509 were Metal resources and data sources (which means they're fairly well covered by tests) and (2) where it was used, it looks like it should be OK to return [] in the cases where that would have returned []-but-actually-nil.

Copy link
Contributor

@ocobles ocobles left a comment

Choose a reason for hiding this comment

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

lgtm. I didn't try it but I tried the playground example

@ctreatma ctreatma merged commit eb69680 into main Jan 12, 2024
4 of 5 checks passed
@ctreatma ctreatma deleted the fix-vrf-ip-ranges-test branch January 12, 2024 18:13
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.

[Bug]: TestAccMetalVRF_withIPRanges is failing consistently in CI
3 participants