dmarkham / enumer

A Go tool to auto generate methods for your enums
Other
410 stars 66 forks source link

The err of func %[1]sString(s string) print a lower case of string #43

Closed Maxence1 closed 3 years ago

Maxence1 commented 3 years ago

Hi team,

I was trying to do some unhappy path test case using //go:generate enumer -type=BusinessType -json -transform upper

And when I test a "does not belong to BusinessType values" case: I entered ABC, and expect to get "ABC does not belong to BusinessType values", but what I get is "abc does not belong to BusinessType values"

I think it's because the generated function BusinessTypeString transformed it into lower case, it's not impacting the code logic, but my test case becomes a little weird:

Input: "ABC"
Output: "abc does not belong to BusinessType values"

The question is, is there any way to generate without the toLower() transform in function BusinessTypeString?

Many thanks!

Best regards,

Maxence1 commented 3 years ago

image

dmarkham commented 3 years ago

Interesting I never thought about this. I feel like it should return the in the error message what ever you pass in. I'll poke around this and see if I can not come up with a patch!

dmarkham commented 3 years ago

@Maxence1 do you have a change to have a look at this to see if it meets your needs?

dmarkham commented 3 years ago

All merged in and should be working as you expected now!