Skip to content

Commit

Permalink
add e2e testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
lindnerby committed Nov 4, 2024
1 parent d6f69d8 commit 9207f2c
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tests/e2e/create/create_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ func Test_Create(t *testing.T) {
const (
testdataDir = "./testdata/moduleconfig/"

invalidConfigs = testdataDir + "invalid/"
duplicateResources = invalidConfigs + "duplicate-resources.yaml"
missingNameConfig = invalidConfigs + "missing-name.yaml"
missingVersionConfig = invalidConfigs + "missing-version.yaml"
missingManifestConfig = invalidConfigs + "missing-manifest.yaml"
missingInfoConfig = invalidConfigs + "missing-info.yaml"
nonHttpsResource = invalidConfigs + "non-https-resource.yaml"
resourceWithoutLink = invalidConfigs + "resource-without-link.yaml"
resourceWithoutName = invalidConfigs + "resource-without-name.yaml"
manifestFileref = invalidConfigs + "manifest-fileref.yaml"
defaultCRFileref = invalidConfigs + "defaultcr-fileref.yaml"
invalidConfigs = testdataDir + "invalid/"
duplicateIcons = invalidConfigs + "duplicate-icons.yaml"
duplicateResources = invalidConfigs + "duplicate-resources.yaml"
missingNameConfig = invalidConfigs + "missing-name.yaml"
missingVersionConfig = invalidConfigs + "missing-version.yaml"
missingManifestConfig = invalidConfigs + "missing-manifest.yaml"
missingDocumentationConfig = invalidConfigs + "missing-documentation.yaml"
missingRepositoryConfig = invalidConfigs + "missing-repository.yaml"
missingIconsConfig = invalidConfigs + "missing-icons.yaml"
nonHttpsResource = invalidConfigs + "non-https-resource.yaml"
resourceWithoutLink = invalidConfigs + "resource-without-link.yaml"
resourceWithoutName = invalidConfigs + "resource-without-name.yaml"
iconsWithoutLink = invalidConfigs + "icons-without-link.yaml"
iconsWithoutName = invalidConfigs + "icons-without-name.yaml"
manifestFileref = invalidConfigs + "manifest-fileref.yaml"
defaultCRFileref = invalidConfigs + "defaultcr-fileref.yaml"

validConfigs = testdataDir + "valid/"
minimalConfig = validConfigs + "minimal.yaml"
Expand Down
56 changes: 56 additions & 0 deletions tests/e2e/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,62 @@ var _ = Describe("Test 'create' command", Ordered, func() {
})
})

Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with missing repository", func() {
cmd = createCmd{
moduleConfigFile: missingRepositoryConfig,
}
})
It("Then the command should fail", func() {
err := cmd.execute()
Expect(err).Should(HaveOccurred())
Expect(err.Error()).Should(ContainSubstring("failed to parse module config: failed to validate module config: failed to validate repository: invalid Option: must not be empty"))
})
})

Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with missing documentation", func() {
cmd = createCmd{
moduleConfigFile: missingDocumentationConfig,
}
})
It("Then the command should fail", func() {
err := cmd.execute()
Expect(err).Should(HaveOccurred())
Expect(err.Error()).Should(ContainSubstring("failed to parse module config: failed to validate module config: failed to validate documentation: invalid Option: must not be empty"))
})
})

Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with missing icons", func() {
cmd = createCmd{
moduleConfigFile: missingIconsConfig,
}
})
It("Then the command should fail", func() {
err := cmd.execute()
Expect(err).Should(HaveOccurred())
Expect(err.Error()).Should(ContainSubstring("failed to parse module config: failed to validate module config: failed to validate icons: invalid Option: must not be empty"))
})
})

Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with duplicate entry in icons", func() {
cmd = createCmd{
moduleConfigFile: duplicateIcons,
}
})
It("Then the command should fail", func() {
err := cmd.execute()
Expect(err).Should(HaveOccurred())
Expect(err.Error()).Should(ContainSubstring("failed to parse module config file: icons contain duplicate entries"))
})
})

Context("Given 'modulectl create' command", func() {
var cmd createCmd
It("When invoked with duplicate entry in resources", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
resources:
- name: someResource
link: https://some.other/location/template-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: http://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: kyma-project.io/module/template-operator
version: 1.0.0
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
repository: http://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png

0 comments on commit 9207f2c

Please sign in to comment.