You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of a new plugin testing, we're trying to add dies package to better manage object/resources in unit testing.
However, when running the dies generator command, the autogenerated file comes with a weird import:
apicappsv1"map[whatevergit.com/pkg/app-resource/api/capps/v1"// this is the first import which contains extra characterscappsv1"whatevergit.com/pkg/app-resource/api/capps/v1"// this is the second import, poiting to the same repo but with a different name
and also, the funcs that ask for a map[<customType>]anything, fail by creating the following func signature:
// should be v map[apicappsv1.ContentKey]stringfunc (d*AppSpecDie) Content(v apicappsv1.ContentKey]string) *AppSpecDie {...}
Since ContentKey is type ContentKey string, I tried adding it to my app_types.go file like this:
go run -modfile hack/go.mod -mod=mod dies.dev/diegen die:headerFile="hack/boilerplate.go.txt" paths="./..."
I get the following error:
...
Generating die for"ResourcesKey"
Generating die for"ContentKey"
519:62: missing ','in parameter list # this line is where the map is not properly created for ContentKey
563:66: missing ','in parameter list # this line is where the map is not properly created for ResourcesKey
panic: true
goroutine 1 [running]:
main.main()
/Users/wendyarango/go/pkg/mod/reconciler.io/dies/[email protected]/main.go:45 +0xfc
Is it possible I'm doing something wrong? Thanks for your help
The text was updated successfully, but these errors were encountered:
Yea, maps with non-primitive keys are not handled well. You can work around this by ignoring the specific field that is causing trouble and manually defining the methods you care about.
As part of a new plugin testing, we're trying to add
dies
package to better manage object/resources in unit testing.However, when running the dies generator command, the autogenerated file comes with a weird import:
and also, the funcs that ask for a
map[<customType>]anything
, fail by creating the following func signature:Since
ContentKey
istype ContentKey string
, I tried adding it to myapp_types.go
file like this:When running:
I get the following error:
Is it possible I'm doing something wrong? Thanks for your help
The text was updated successfully, but these errors were encountered: