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

Connection flatten functions to return diagnostics slice instead of error (2/3) #240

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Jul 14, 2022

Description

Small refactor of the connection resource's flatten functions to return diag.Diagnostics instead of a regular error. What this does is allow more specific diagnostic logging to exist alongside the domain-specific code. Otherwise, we would need to maintain some type of mapping between a custom error type and the diagnostic logs within the higher-level flatten function. This unlock is demonstrated in this PR: #241 .

Checklist

Note: Checklist required to be completed before a PR is considered to be reviewable.

Auth0 Code of Conduct

Auth0 General Contribution Guidelines

Changes include test coverage?

  • Yes
  • Not needed

Does the description provide the correct amount of context?

  • Yes, the description provides enough context for the reviewer to understand what these changes accomplish

Have you updated the documentation?

  • Yes, I've updated the appropriate docs
  • Not needed

Is this code ready for production?

  • Yes, all code changes are intentional and no debugging calls are left over

@willvedd willvedd requested a review from a team as a code owner July 14, 2022 20:13

import "testing"

func TestFlattenConnectionOptions(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I always wondered why we didn't unit test the flatten function because there is quite a bit of logic and complexity wrapped up in them. However, this test is just asserting the simple case of a nil options struct which should return nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file will also serve as the holding place to test the existence of specific diagnostic information like warnings.

@willvedd willvedd changed the title Connection flatten functions to return diagnostics slice instead of error Connection flatten functions to return diagnostics slice instead of error (2/3) Jul 14, 2022
sergiught
sergiught previously approved these changes Jul 15, 2022
Base automatically changed from add-auth-params-passwordless-connections to main July 15, 2022 14:35
@sergiught sergiught force-pushed the flatten-connection-options-return-diag-type branch 2 times, most recently from d73739e to da61912 Compare July 15, 2022 14:39
@codecov-commenter
Copy link

Codecov Report

Merging #240 (da61912) into main (55081cb) will increase coverage by 0.02%.
The diff coverage is 62.50%.

@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
+ Coverage   82.64%   82.67%   +0.02%     
==========================================
  Files          36       36              
  Lines        6850     6861      +11     
==========================================
+ Hits         5661     5672      +11     
  Misses        938      938              
  Partials      251      251              
Impacted Files Coverage Δ
auth0/resource_auth0_connection.go 71.33% <33.33%> (ø)
auth0/structure_auth0_connection.go 84.10% <63.76%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55081cb...da61912. Read the comment docs.

@sergiught sergiught force-pushed the flatten-connection-options-return-diag-type branch from da61912 to e53edb4 Compare July 15, 2022 14:44
@sergiught sergiught merged commit b93cfad into main Jul 15, 2022
@sergiught sergiught deleted the flatten-connection-options-return-diag-type branch July 15, 2022 14:47
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.

3 participants