@@ -444,6 +444,18 @@ func TestAnnotatedWrongUsage(t *testing.T) {
444444 )
445445 assert .Contains (t , app .Err ().Error (), "embeds a dig.In" , "expected error when result types were annotated" )
446446 })
447+
448+ t .Run ("invalid group option" , func (t * testing.T ) {
449+ t .Parallel ()
450+
451+ app := NewForTest (t ,
452+ fx .Provide (
453+ fx .Annotate (func () string { return "sad times" },
454+ fx .ResultTags (`group:"foo,soft"` )),
455+ ),
456+ )
457+ assert .Contains (t , app .Err ().Error (), "cannot use soft with result value groups" , "expected error when invalid group option is provided" )
458+ })
447459}
448460
449461func TestAnnotatedString (t * testing.T ) {
@@ -642,6 +654,34 @@ func TestAnnotate(t *testing.T) {
642654 assert .Contains (t , err .Error (), `missing type: []*fx_test.a[name="a"]` )
643655 })
644656
657+ t .Run ("Invoke function with soft group param" , func (t * testing.T ) {
658+ t .Parallel ()
659+ newF := func (foos []int , bar string ) {
660+ assert .ElementsMatch (t , []int {10 }, foos )
661+ }
662+ app := fxtest .New (t ,
663+ fx .Provide (
664+ fx .Annotate (
665+ func () (int , string ) { return 10 , "hello" },
666+ fx .ResultTags (`group:"foos"` ),
667+ ),
668+ fx .Annotate (
669+ func () int {
670+ require .FailNow (t , "this function should not be called" )
671+ return 20
672+ },
673+ fx .ResultTags (`group:"foos"` ),
674+ ),
675+ ),
676+ fx .Invoke (
677+ fx .Annotate (newF , fx .ParamTags (`group:"foos,soft"` )),
678+ ),
679+ )
680+
681+ defer app .RequireStart ().RequireStop ()
682+ require .NoError (t , app .Err ())
683+ })
684+
645685 t .Run ("Invoke variadic function with multiple params" , func (t * testing.T ) {
646686 t .Parallel ()
647687
@@ -984,7 +1024,6 @@ func TestAnnotate(t *testing.T) {
9841024 assert .Contains (t , err .Error (), "invalid annotation function func(fx_test.B) string" )
9851025 assert .Contains (t , err .Error (), "fx.In structs cannot be annotated" )
9861026 })
987-
9881027}
9891028
9901029func assertApp (
@@ -1279,7 +1318,6 @@ func TestHookAnnotations(t *testing.T) {
12791318 require .Equal (t , "constructor" , <- ch )
12801319 require .Equal (t , "decorated" , <- ch )
12811320 })
1282-
12831321}
12841322
12851323func TestHookAnnotationFailures (t * testing.T ) {
0 commit comments