Skip to content

Commit

Permalink
OCM-5677 | feat: Added rosa describe autoscaler command
Browse files Browse the repository at this point in the history
  • Loading branch information
robpblake committed Mar 21, 2024
1 parent 47a0009 commit 2b5b12b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cmd/describe/autoscaler/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package autoscaler
import (
"context"
"fmt"
"net/http"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -57,7 +58,7 @@ var _ = Describe("rosa describe autoscaler", func() {

It("Returns an error if the cluster does not exist", func() {

t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList(make([]*cmv1.Cluster, 0))))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList(make([]*cmv1.Cluster, 0))))
t.SetCluster("cluster", nil)

runner := DescribeAutoscalerRunner()
Expand All @@ -75,7 +76,7 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -90,7 +91,7 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -105,11 +106,11 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.RouteToHandler(
"GET",
fmt.Sprintf("/api/clusters_mgmt/v1/clusters/%s/autoscaler", cluster.ID()),
RespondWithJSON(500, "{}"))
RespondWithJSON(http.StatusInternalServerError, "{}"))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -125,8 +126,8 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(404, "{}"))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusNotFound, "{}"))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -142,10 +143,10 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))

autoscaler := MockAutoscaler(nil)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatResource(autoscaler)))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatResource(autoscaler)))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -162,10 +163,10 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))

autoscaler := MockAutoscaler(nil)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatResource(autoscaler)))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatResource(autoscaler)))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand All @@ -183,10 +184,10 @@ var _ = Describe("rosa describe autoscaler", func() {
})

t.SetCluster(cluster.Name(), cluster)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatClusterList([]*cmv1.Cluster{cluster})))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatClusterList([]*cmv1.Cluster{cluster})))

autoscaler := MockAutoscaler(nil)
t.ApiServer.AppendHandlers(RespondWithJSON(200, FormatResource(autoscaler)))
t.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, FormatResource(autoscaler)))

runner := DescribeAutoscalerRunner()
err := runner(context.Background(), t.RosaRuntime, nil, nil)
Expand Down

0 comments on commit 2b5b12b

Please sign in to comment.