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

Expose "Group" Provide option #225

Merged
merged 8 commits into from
Nov 15, 2018
Merged

Conversation

vyshah
Copy link
Contributor

@vyshah vyshah commented Nov 14, 2018

The commits are mostly individually reviewable.

This is a step towards a solution for #610 (fx) for both named values and value groups. This will allow fx to expose its own Group option, which will allow users to form value groups without needing fx.Out.

@glibsm
Copy link
Collaborator

glibsm commented Nov 14, 2018

Including an early (even if it's breaking) test case would be really beneficial to this review so people can see the intended usage and outcome

dig.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 14, 2018

Codecov Report

Merging #225 into master will decrease coverage by 0.23%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #225      +/-   ##
=========================================
- Coverage   98.64%   98.4%   -0.24%     
=========================================
  Files           9       9              
  Lines        1104    1130      +26     
=========================================
+ Hits         1089    1112      +23     
- Misses         11      13       +2     
- Partials        4       5       +1
Impacted Files Coverage Δ
dig.go 98.81% <100%> (+0.07%) ⬆️
result.go 98.08% <40%> (-1.92%) ⬇️

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 6251038...893547b. Read the comment docs.

@vyshah vyshah changed the title [WIP] Expose "Group" Provide option Expose "Group" Provide option Nov 14, 2018
@vyshah
Copy link
Contributor Author

vyshah commented Nov 14, 2018

@glibsm tests have been added :)

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

mostly lgtm.

couple testing nits and suggesting another test case.

}

require.NoError(t, c.Invoke(func(i in) {
assert.Equal(t, []int{2, 3, 1}, i.Values)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can avoid need for setting the rand seed by using assert.ElementsMatch

dig_test.go Outdated
return out{Value: i}
}, Group("val")), "This Provide should fail")
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

function unnecessary here since this is called exactly once. consider inlining it.

require.Error(t, c.Provide(...))

The contents of the function can also mark the test as failed to guarantee that it's never called.

func() out {
  t.Fatal("this function should never be called")
  return out{}
}

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 may be subjective but inlining it breaks the format followed by surrounding tests and makes it a little harder to read.

dig_test.go Show resolved Hide resolved
@vyshah vyshah merged commit 71bfa11 into uber-go:master Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants