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

Check paniced when using OneGenOf #83

Open
vedujoshi opened this issue Sep 9, 2021 · 1 comment
Open

Check paniced when using OneGenOf #83

vedujoshi opened this issue Sep 9, 2021 · 1 comment

Comments

@vedujoshi
Copy link

vedujoshi commented Sep 9, 2021

Sometimes we get a failure with the below code

Error on property evaluation after 1 passed
   tests: Check paniced: reflect: Call using *schema.PathMatcherType_Prefix
   as type *schema.PathMatcherType_Path

Could you please suggest if you see any issue ?

Code:

func genPathMatcherType() gopter.Gen {
	return gen.StructPtr(reflect.TypeOf(&pb_schema.PathMatcherType{}), map[string]gopter.Gen{
		"PathMatch": gen.OneGenOf(genPathMatcherType_Prefix(), genPathMatcherType_Path(), genPathMatcherType_Regex()),
	})
}
func genPathMatcherType_Prefix() gopter.Gen {
	return gen.StructPtr(reflect.TypeOf(&pb_schema.PathMatcherType_Prefix{}), map[string]gopter.Gen{
		"Prefix": gen.AlphaString(),
	})
}
func genPathMatcherType_Path() gopter.Gen {
	return gen.StructPtr(reflect.TypeOf(&pb_schema.PathMatcherType_Path{}), map[string]gopter.Gen{
		"Path": gen.AlphaString(),
	})
}
func genPathMatcherType_Regex() gopter.Gen {
	return gen.StructPtr(reflect.TypeOf(&pb_schema.PathMatcherType_Regex{}), map[string]gopter.Gen{
		"Regex": gen.AlphaString(),
	})
}

@untoldwind
Copy link
Collaborator

It looks right to me (provided the structs have these string fields).
Do you have more information where the panic occurs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants