Skip to content

Commit

Permalink
Fix bug in Properties()
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek committed Jun 14, 2021
1 parent 9f53aca commit d190653
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hack/generator/pkg/astmodel/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ func (resource *ResourceType) Properties() []*PropertyDefinition {
result = append(result, resource.createStatusProperty())
}

for _, property := range resource.properties {
result = append(result, property)
}

// Sorted so that it's always consistent
sort.Slice(result, func(left int, right int) bool {
return result[left].propertyName < result[right].propertyName
})

return result
}

Expand Down
8 changes: 8 additions & 0 deletions hack/generator/pkg/astmodel/resource_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ func TestResourceType_Property_ForSpec_ReturnsProperty(t *testing.T) {
* WithProperty() tests
*/

func TestResourceType_WithProperty_HasExpectedLength(t *testing.T) {
g := NewGomegaWithT(t)
base := NewResourceType(emptySpec, emptyStatus)
ownerProp := NewPropertyDefinition("Owner", "owner", StringType)
resource := base.WithProperty(ownerProp)
g.Expect(resource.Properties()).To(HaveLen(3))
}

func TestResourceType_WithProperty_IncludesProperty(t *testing.T) {
g := NewGomegaWithT(t)
base := NewResourceType(emptySpec, emptyStatus)
Expand Down

0 comments on commit d190653

Please sign in to comment.