Skip to content

Commit

Permalink
🧪 Added testcases for ResizeWorkerPool() API.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakshnd authored and hkantare committed Feb 3, 2022
1 parent 1bc4f90 commit 641e660
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions api/container/containerv2/worker_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,55 @@ var _ = Describe("workerpools", func() {
Expect(err).To(HaveOccurred())
})
})

//Resize
Describe("Resize", func() {
Context("When resizing workerpool is successful", func() {
BeforeEach(func() {
server = ghttp.NewServer()
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v2/resizeWorkerPool"),
ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","workerpool":"mywork211","size":5}`),
),
)
})
It("should resize Workerpool in a cluster", func() {
target := ClusterTargetHeader{}
params := ResizeWorkerPoolReq{
Cluster: "bm64u3ed02o93vv36hb0",
Workerpool: "mywork211",
Size: 5,
}
err := newWorkerPool(server.URL()).ResizeWorkerPool(params, target)
Expect(err).NotTo(HaveOccurred())
})
})
Context("When resizing workerpool is unsuccessful", func() {
BeforeEach(func() {
server = ghttp.NewServer()
server.SetAllowUnhandledRequests(true)
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v2/resizeWorkerPool"),
ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","workerpool":"mywork211","size":5}`),
ghttp.RespondWith(http.StatusInternalServerError, `Failed to resize workerpool`),
),
)
})

It("should return error during resizing workerpool", func() {
params := ResizeWorkerPoolReq{
Cluster: "bm64u3ed02o93vv36hb0",
Workerpool: "mywork211",
Size: 5,
}
target := ClusterTargetHeader{}
err := newWorkerPool(server.URL()).ResizeWorkerPool(params, target)
Expect(err).To(HaveOccurred())
})
})
})
})
})

Expand Down

0 comments on commit 641e660

Please sign in to comment.