Skip to content

Commit

Permalink
lint, add test for mismatched delivery inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Ritchie committed Oct 19, 2021
1 parent a86d384 commit 08d88b7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 0 additions & 1 deletion pkg/apis/v1alpha1/cluster_delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type ClusterDeliveryList struct {
Items []ClusterDelivery `json:"items"`
}


func (c *ClusterDelivery) ValidateCreate() error {
return validateNewState(c)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/v1alpha1/cluster_delivery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package v1alpha1_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware-tanzu/cartographer/pkg/apis/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/vmware-tanzu/cartographer/pkg/apis/v1alpha1"
)

var _ = Describe("Delivery Validation", func() {
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/delivery/delivery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,33 @@ var _ = Describe("Deliveries", func() {

})
})

Describe("the inputs are mismatched", func() {
BeforeEach(func() {
deliveryYaml := utils.HereYaml(`
---
apiVersion: carto.run/v1alpha1
kind: ClusterDelivery
metadata:
name: my-delivery
spec:
resources:
- name: my-first-resource
templateRef:
kind: ClusterImageTemplate
name: kpack-battery
`)

delivery = &unstructured.Unstructured{}
err := yaml.Unmarshal([]byte(deliveryYaml), delivery)
Expect(err).NotTo(HaveOccurred())
})

It("Rejects the delivery chain", func() {
err := c.Create(ctx, delivery)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("ClusterDelivery.carto.run \"my-delivery\" is invalid: spec.resources.templateRef.kind: Unsupported value: \"ClusterImageTemplate\""))
})
})

})

0 comments on commit 08d88b7

Please sign in to comment.