Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmendelope committed Aug 12, 2021
1 parent d0a28b8 commit a5fbe34
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions internal/pkg/server/catalog-manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,44 @@ var _ = ginkgo.Describe("Catalog handler test", func() {
gomega.Expect(received).Should(gomega.BeEmpty())
})
})

ginkgo.Context("Adding applications", func() {
ginkgo.It("Should be able to add an application", func() {

namespace := "namespace"
appName := "app"
tag := "v1.0"
filesReturned := []*entities.FileInfo{
{
Path: "./app.yaml",
Data: []byte("Kind: ApplicationConfiguration"),
}, {
Path: "./metadata.yaml",
Data: []byte(metadataFile),
}}
metadataProvider.EXPECT().Add(gomock.Any()).Return(nil, nil)
storageProvider.EXPECT().StoreApplication(namespace, appName, tag, gomock.Any()).Return(nil)

manager := NewManager(storageProvider, metadataProvider, "")
err := manager.Add(fmt.Sprintf("%s/%s:%s", namespace, appName, tag), filesReturned)
gomega.Expect(err).Should(gomega.Succeed())
})
ginkgo.It("Should not be able to add an application if the namespace is wrong", func() {

namespace := "Namespace"
appName := "app"
tag := "v1.0"
filesReturned := []*entities.FileInfo{
{
Path: "./app.yaml",
Data: []byte("Kind: ApplicationConfiguration"),
}, {
Path: "./metadata.yaml",
Data: []byte(metadataFile),
}}
manager := NewManager(storageProvider, metadataProvider, "")
err := manager.Add(fmt.Sprintf("%s/%s:%s", namespace, appName, tag), filesReturned)
gomega.Expect(err).ShouldNot(gomega.Succeed())
})
})
})

0 comments on commit a5fbe34

Please sign in to comment.