entc/gen: don't rely on descriptor when retrieving enum values or names to ease extension testibility (#2211)

Trying to add tests to some extensions and this is complicating things a lot because `Field.def` is unexported. Not taking the length of `def.Enums` but `Enums` directly fixes this. It technically is also more correct, because `f.Enums` could be greater than `f.def.Enums`.
This commit is contained in:
MasseElch
2021-12-11 13:25:02 +01:00
committed by GitHub
parent 5dddeef736
commit 76770e8a52

View File

@@ -896,7 +896,7 @@ func (f Field) StructField() string {
// EnumNames returns the enum values of a field.
func (f Field) EnumNames() []string {
names := make([]string, 0, len(f.def.Enums))
names := make([]string, 0, len(f.Enums))
for _, e := range f.Enums {
names = append(names, e.Name)
}
@@ -905,7 +905,7 @@ func (f Field) EnumNames() []string {
// EnumValues returns the values of the enum field.
func (f Field) EnumValues() []string {
values := make([]string, 0, len(f.def.Enums))
values := make([]string, 0, len(f.Enums))
for _, e := range f.Enums {
values = append(values, e.Value)
}