Skip to content

Commit

Permalink
OCM-7254 | feat: Move edit machinepool non-cmd funcs to pkg and test
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterkepley committed Jul 1, 2024
1 parent de37e9d commit eeb9d94
Show file tree
Hide file tree
Showing 10 changed files with 898 additions and 963 deletions.
9 changes: 3 additions & 6 deletions cmd/edit/machinepool/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"

mpHelpers "github.com/openshift/rosa/pkg/helper/machinepools"
"github.com/openshift/rosa/pkg/machinepool"
"github.com/openshift/rosa/pkg/ocm"
"github.com/openshift/rosa/pkg/rosa"
)
Expand Down Expand Up @@ -180,12 +181,8 @@ func run(cmd *cobra.Command, argv []string) {
}
}

var err error
if cluster.Hypershift().Enabled() {
err = editNodePool(cmd, machinePoolID, clusterKey, cluster, r)
} else {
err = editMachinePool(cmd, machinePoolID, clusterKey, cluster, r)
}
service := machinepool.NewMachinePoolService()
err := service.EditMachinePool(cmd, machinePoolID, clusterKey, cluster, r)
if err != nil {
r.Reporter.Errorf("%s", err)
os.Exit(1)
Expand Down
33 changes: 33 additions & 0 deletions cmd/edit/machinepool/cmd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package machinepool

import (
. "github.com/onsi/ginkgo/v2"
)

// Will un-comment and become the cmd test once the work on refactoring this command is finalized
var _ = Describe("Edit Machinepool", func() {

/*Context("getNodePoolReplicas", func() {
nodePoolId := "test-nodepool"
It("KO: Fails if autoscaling is not set", func() {
Cmd.Flags().Set("min-replicas", "2")
_, _, _, _, err := getNodePoolReplicas(
Cmd, rosa.NewRuntime().Reporter, nodePoolId, 2, nil, true)
Expect(err).Error().Should(HaveOccurred())
Expect(err.Error()).To(Equal(
"Autoscaling is not enabled on machine pool 'test-nodepool'. can't set min or max replicas"))
})
It("KO: Fails to set replicas if autoscaling is enabled", func() {
autoScaling := &cmv1.NodePoolAutoscaling{}
Cmd.Flags().Set("enable-autoscaling", "true")
Cmd.Flags().Set("replicas", "3")
_, _, _, _, err := getNodePoolReplicas(
Cmd, rosa.NewRuntime().Reporter, nodePoolId, 2, autoScaling, true)
Expect(err).Error().Should(HaveOccurred())
Expect(err.Error()).To(Equal("Autoscaling enabled on machine pool 'test-nodepool'. can't set replicas"))
})
})*/
})
245 changes: 0 additions & 245 deletions cmd/edit/machinepool/machinepool.go

This file was deleted.

56 changes: 0 additions & 56 deletions cmd/edit/machinepool/machinepool_test.go

This file was deleted.

Loading

0 comments on commit eeb9d94

Please sign in to comment.