## Description Ref #12036 Depends on app wiring for x/distribution getting merged first (#12292) --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package depinject_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/regen-network/gocuke"
|
|
"gotest.tools/v3/assert"
|
|
|
|
"github.com/cosmos/cosmos-sdk/depinject"
|
|
)
|
|
|
|
func TestInvoke(t *testing.T) {
|
|
gocuke.NewRunner(t, &invokeSuite{}).
|
|
Path("features/invoke.feature").
|
|
Run()
|
|
}
|
|
|
|
type invokeSuite struct {
|
|
gocuke.TestingT
|
|
configs []depinject.Config
|
|
i int
|
|
sp *string
|
|
}
|
|
|
|
func (s *invokeSuite) AnInvokerRequestingAnIntAndStringPointer() {
|
|
s.configs = append(s.configs, depinject.Invoke(s.intStringPointerInvoker))
|
|
}
|
|
|
|
func (s *invokeSuite) intStringPointerInvoker(i int, sp *string) {
|
|
s.i = i
|
|
s.sp = sp
|
|
}
|
|
|
|
func (s *invokeSuite) TheContainerIsBuilt() {
|
|
assert.NilError(s, depinject.Inject(depinject.Configs(s.configs...)))
|
|
}
|
|
|
|
func (s *invokeSuite) TheInvokerWillGetTheIntParameterSetTo(a int64) {
|
|
assert.Equal(s, int(a), s.i)
|
|
}
|
|
|
|
func (s *invokeSuite) TheInvokerWillGetTheStringPointerParameterSetToNil() {
|
|
if s.sp != nil {
|
|
s.Fatalf("expected a nil string pointer, got %s", *s.sp)
|
|
}
|
|
}
|
|
|
|
func (s *invokeSuite) AnIntProviderReturning(a int64) {
|
|
s.configs = append(s.configs, depinject.Provide(func() int { return int(a) }))
|
|
}
|
|
|
|
func (s *invokeSuite) AStringPointerProviderPointingTo(a string) {
|
|
s.configs = append(s.configs, depinject.Provide(func() *string { return &a }))
|
|
}
|
|
|
|
func (s *invokeSuite) TheInvokerWillGetTheStringPointerParameterSetTo(a string) {
|
|
if s.sp == nil {
|
|
s.Fatalf("expected a non-nil string pointer")
|
|
}
|
|
assert.Equal(s, a, *s.sp)
|
|
}
|
|
|
|
func (s *invokeSuite) AnInvokerRequestingAnIntAndStringPointerRunInModule(a string) {
|
|
s.configs = append(s.configs, depinject.InvokeInModule(a, s.intStringPointerInvoker))
|
|
}
|
|
|
|
func (s *invokeSuite) AModulescopedIntProviderWhichReturnsTheLengthOfTheModuleName() {
|
|
s.configs = append(s.configs, depinject.Provide(func(key depinject.ModuleKey) int {
|
|
return len(key.Name())
|
|
}))
|
|
}
|