Closed matthewhartstonge closed 2 years ago
Thanks for the PR, @matthewhartstonge This looks quite go-ish ( included in the go tour https://tour.golang.org/methods/18 for example ).
Can you please add a test ( https://github.com/FusionAuth/go-client/blob/master/pkg/fusionauth/Client_test.go or https://github.com/FusionAuth/go-client/blob/master/pkg/fusionauth/Domain_test.go are the right places).
Hey @mooreds, i'm wondering if it might be better to generate the tests programmatically for this?
Otherwise you may need to manually maintain a list of enums to iterate over and test for interface conformance.
i.e.
// domain_test.go
import "testing"
func Test_${d.type}ImplementsStringer(t *testing.T) {
enum := ${d.type}("Test")
if _, ok := enum.(fmt.Stringer); !ok {
t.Errorf("${d.type} does not implement stringer interface\n")
}
}
Good point. I'll take a look at using something like what you suggested.
Being a lazy developer plugging into other systems (i.e. terraform) I want to be able to get string representations of enums, and IDE autocomplete using:
Instead of having to manually typecast every enum:
This will also enable being able to be a bit more smart enum based functions by being able to cast enums to the Stringer interface to do things over multiple types. As a trivial example:
started from: https://github.com/FusionAuth/go-client/pull/59