Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amritanshusikdar committed Oct 28, 2024
1 parent e7ba239 commit f033ca3
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tests/e2e/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ package create_test
import (
"io/fs"
"os"
"strings"

"k8s.io/apimachinery/pkg/util/yaml"
"ocm.software/ocm/api/ocm"
"ocm.software/ocm/api/ocm/compdesc"
ocmv1 "ocm.software/ocm/api/ocm/compdesc/meta/v1"
"ocm.software/ocm/api/ocm/compdesc/versions/v2"
v2 "ocm.software/ocm/api/ocm/compdesc/versions/v2"
"ocm.software/ocm/api/ocm/extensions/accessmethods/github"
"ocm.software/ocm/api/ocm/extensions/accessmethods/localblob"
"ocm.software/ocm/api/ocm/extensions/accessmethods/ociartifact"
Expand Down Expand Up @@ -219,9 +218,7 @@ var _ = Describe("Test 'create' command", Ordered, func() {
Expect(descriptor).ToNot(BeNil())
Expect(descriptor.SchemaVersion()).To(Equal(v2.SchemaVersion))

descriptorSplit := strings.Split(descriptor.Name, "/")
descriptorName := descriptorSplit[len(descriptorSplit)-1]
Expect(template.Name).To(Equal(descriptorName + "-" + descriptor.Version))
Expect(template.Name).To(Equal("template-operator-1.0.0"))

By("And annotations should be correct")
annotations := template.Annotations
Expand Down Expand Up @@ -308,6 +305,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.1"))

By("And new annotation should be correctly added")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.1"))
Expand Down Expand Up @@ -342,6 +341,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.2"))

By("And annotation should have correct version")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.2"))
Expand Down Expand Up @@ -389,6 +390,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.3"))

By("And descriptor.component.resources should be correct")
Expect(descriptor.Resources).To(HaveLen(2))
resource := descriptor.Resources[0]
Expand Down Expand Up @@ -464,6 +467,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.4"))

By("And annotation should have correct version")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.4"))
Expand Down Expand Up @@ -495,6 +500,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.5"))

By("And annotation should have correct version")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.5"))
Expand Down Expand Up @@ -533,6 +540,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.6"))

By("And annotation should have correct version")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.6"))
Expand All @@ -547,14 +556,13 @@ var _ = Describe("Test 'create' command", Ordered, func() {
Expect(manager.Kind).To(Equal("Deployment"))
})
})



Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with valid module-config containing associatedResources list", func() {
cmd = createCmd{
moduleConfigFile: withAssociatedResourcesConfig,
registry: ociRegistry,
registry: ociRegistry,
insecure: true,
output: templateOutputPath,
}
Expand All @@ -571,6 +579,8 @@ var _ = Describe("Test 'create' command", Ordered, func() {
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())

Expect(template.Name).To(Equal("template-operator-1.0.7"))

By("And annotation should have correct version")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.7"))
Expand Down

0 comments on commit f033ca3

Please sign in to comment.