Repository: uber-go/fx
Pull request #851 (2022-02-25 22:39:10)

Modify non compliant decoration test
This modifies a test that was added in a previous commit which highlights
a problematic transitive decoration of a parent-module provided-type.

Specifically, consider the following case:
* Parent Module provides type A, and type B which depends on type A.
* Child Module decorates type A and invokes something that depends on type B.

In such case, the invoked function in child Module should not see a version of
type B created with a decorated type A.

This is because the constructor for the type B lives outside the scope of the
decoration. The decoration can only affect child Scope's providers, and should
not affect parent-provided constructor directly.

This test case is not compliant with such case, so it should be modified.

This also pins Dig dependency to latest commit of Dig's master branch to take
in the fix made in https://github.com/uber-go/dig/pull/325.

codecov[bot]: # [Codecov](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) Report
> Merging [#851](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (73a4997) into [master](https://codecov.io/gh/uber-go/fx/commit/e279a3deb9a4bffa5db5958249ec1a7be10a4bd8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (e279a3d) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/uber-go/fx/pull/851/graphs/tree.svg?width=650&height=150&src=pr&token=PYY9PSfaC6&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)

```diff
@@           Coverage Diff           @@
##           master     #851   +/-   ##
=======================================
  Coverage   98.45%   98.45%           
=======================================
  Files          30       30           
  Lines        1100     1100           
=======================================
  Hits         1083     1083           
  Misses         11       11           
  Partials        6        6           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Last update [e279a3d...73a4997](https://codecov.io/gh/uber-go/fx/pull/851?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).


Patch:
diff --git a/go.mod b/go.mod
index 0285efb..2dfc5b0 100644
--- a/go.mod
+++ b/go.mod
@@ -12,4 +12,4 @@ require (
 	golang.org/x/sys v0.0.0-20210903071746-97244b99971b
 )
 
-replace go.uber.org/dig => github.com/uber-go/dig v1.13.1-0.20220217170604-a7e23e31e975
+replace go.uber.org/dig => github.com/uber-go/dig v1.13.1-0.20220225222603-677f64b9c694
diff --git a/go.sum b/go.sum
index 640af25..f82117b 100644
--- a/go.sum
+++ b/go.sum
@@ -22,8 +22,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/uber-go/dig v1.13.1-0.20220217170604-a7e23e31e975 h1:DThTt5qayrILkBHJQIu19u38oTPaWH/LU+RxMLz0/tA=
-github.com/uber-go/dig v1.13.1-0.20220217170604-a7e23e31e975/go.mod h1:jHAn/z1Ld1luVVyGKOAIFYz/uBFqKjjEEdIqVAqfQ2o=
+github.com/uber-go/dig v1.13.1-0.20220225222603-677f64b9c694 h1:0PS9oNOB6x8htJywKfuZ2jx3Ax9F8YlImH31Rb/Hc2E=
+github.com/uber-go/dig v1.13.1-0.20220225222603-677f64b9c694/go.mod h1:jHAn/z1Ld1luVVyGKOAIFYz/uBFqKjjEEdIqVAqfQ2o=
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
 go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=


Test patch:
diff --git a/decorate_test.go b/decorate_test.go
index 87db3f5..fb60f23 100644
--- a/decorate_test.go
+++ b/decorate_test.go
@@ -234,7 +234,7 @@ func TestDecorateSuccess(t *testing.T) {
 		defer app.RequireStart().RequireStop()
 	})
 
-	t.Run("transitive and scoped decorations", func(t *testing.T) {
+	t.Run("ineffective transitive decoration", func(t *testing.T) {
 		type Config struct {
 			Scope string
 		}
@@ -254,8 +254,10 @@ func TestDecorateSuccess(t *testing.T) {
 				fx.Decorate(func() *Config {
 					return &Config{Scope: "child"}
 				}),
+				// Logger does not get replaced since it was provided
+				// from a different Scope.
 				fx.Invoke(func(l *Logger) {
-					assert.Equal(t, "child logger", l.Cfg.Scope)
+					assert.Equal(t, "root logger", l.Cfg.Scope)
 				}),
 			),
 		)