|
| 1 | +package bandwidth_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + . "github.com/onsi/ginkgo" |
| 7 | + . "github.com/onsi/gomega" |
| 8 | + |
| 9 | + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" |
| 10 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/bandwidth" |
| 11 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" |
| 12 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" |
| 13 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/utils" |
| 14 | +) |
| 15 | + |
| 16 | +func TestManagers(t *testing.T) { |
| 17 | + RegisterFailHandler(Fail) |
| 18 | + RunSpecs(t, "Report Suite") |
| 19 | +} |
| 20 | + |
| 21 | +var availableCommands = []string{ |
| 22 | + "pools", |
| 23 | + "pools-detail", |
| 24 | + "summary", |
| 25 | +} |
| 26 | + |
| 27 | +// This test suite exists to make sure commands don't get accidently removed from the actionBindings |
| 28 | +var _ = Describe("Test bandwidth commands", func() { |
| 29 | + fakeUI := terminal.NewFakeUI() |
| 30 | + fakeSession := testhelpers.NewFakeSoftlayerSession(nil) |
| 31 | + slMeta := metadata.NewSoftlayerCommand(fakeUI, fakeSession) |
| 32 | + |
| 33 | + Context("New commands testable", func() { |
| 34 | + commands := bandwidth.SetupCobraCommands(slMeta) |
| 35 | + |
| 36 | + var arrayCommands = []string{} |
| 37 | + for _, command := range commands.Commands() { |
| 38 | + commandName := command.Name() |
| 39 | + arrayCommands = append(arrayCommands, commandName) |
| 40 | + It("available commands "+commands.Name(), func() { |
| 41 | + available := false |
| 42 | + if utils.StringInSlice(commandName, availableCommands) != -1 { |
| 43 | + available = true |
| 44 | + } |
| 45 | + Expect(available).To(BeTrue(), commandName+" not found in array available Commands") |
| 46 | + }) |
| 47 | + } |
| 48 | + for _, command := range availableCommands { |
| 49 | + commandName := command |
| 50 | + It("ibmcloud sl "+commands.Name(), func() { |
| 51 | + available := false |
| 52 | + if utils.StringInSlice(commandName, arrayCommands) != -1 { |
| 53 | + available = true |
| 54 | + } |
| 55 | + Expect(available).To(BeTrue(), commandName+" not found in ibmcloud sl "+commands.Name()) |
| 56 | + }) |
| 57 | + } |
| 58 | + }) |
| 59 | + |
| 60 | + Context("Report Namespace", func() { |
| 61 | + It("Report Name Space", func() { |
| 62 | + Expect(bandwidth.BandwidthNamespace().ParentName).To(ContainSubstring("sl")) |
| 63 | + Expect(bandwidth.BandwidthNamespace().Name).To(ContainSubstring("bandwidth")) |
| 64 | + Expect(bandwidth.BandwidthNamespace().Description).To(ContainSubstring("Classic Infrastructure Bandwidth commands")) |
| 65 | + }) |
| 66 | + }) |
| 67 | +}) |
0 commit comments