Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
fix(cli/osm): error when adding osm control plane ns to mesh
Browse files Browse the repository at this point in the history
    This has changes to return an error when a user tries to add
    a ns which has osm control plane installed to the mesh.
    This will fix #1196.
  • Loading branch information
Sheshagiri committed Aug 15, 2020
1 parent 522f189 commit 08adcea
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/cli/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ var _ = Describe("Running the namespace add command", func() {
Expect(out.String()).To(Equal(fmt.Sprintf("Namespace [%s] successfully added to mesh [%s]\nNamespace [%s] successfully added to mesh [%s]\n", testNamespace, testMeshName, testNamespace2, testMeshName)))
})
})
Context("given one namespace with osm-controller installed in it as an arg", func() {
BeforeEach(func() {
out = new(bytes.Buffer)
fakeClientSet = fake.NewSimpleClientset()
// mimic osm controller deployment in testNamespace
deploymentSpec := createDeploymentSpec(testNamespace, defaultMeshName)
fakeClientSet.AppsV1().Deployments(testNamespace).Create(context.TODO(), deploymentSpec, metav1.CreateOptions{})

nsSpec := createNamespaceSpec(testNamespace, "")
fakeClientSet.CoreV1().Namespaces().Create(context.TODO(), nsSpec, metav1.CreateOptions{})

namespaceAddCmd := &namespaceAddCmd{
out: out,
meshName: testMeshName,
namespaces: []string{testNamespace},
clientSet: fakeClientSet,
}

err = namespaceAddCmd.run()
})
It("should not error", func() {
Expect(err).NotTo(HaveOccurred())
})

It("should give a warning message", func() {
Expect(out.String()).To(Equal(fmt.Sprintf("Namespace [%s] already has osm-controller installed and cannot be added to mesh [%s]\n", testNamespace, testMeshName)))
})
})
})

Describe("with non-existent namespace", func() {
Expand Down

0 comments on commit 08adcea

Please sign in to comment.