|
| 1 | +package cdn_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" |
| 5 | + . "github.com/onsi/ginkgo" |
| 6 | + . "github.com/onsi/gomega" |
| 7 | + "github.com/softlayer/softlayer-go/session" |
| 8 | + |
| 9 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/cdn" |
| 10 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata" |
| 11 | + "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers" |
| 12 | +) |
| 13 | + |
| 14 | +var _ = Describe("Cdn origin-remove", func() { |
| 15 | + var ( |
| 16 | + fakeUI *terminal.FakeUI |
| 17 | + cliCommand *cdn.OriginRemoveCommand |
| 18 | + fakeSession *session.Session |
| 19 | + slCommand *metadata.SoftlayerCommand |
| 20 | + ) |
| 21 | + BeforeEach(func() { |
| 22 | + fakeUI = terminal.NewFakeUI() |
| 23 | + fakeSession = testhelpers.NewFakeSoftlayerSession([]string{}) |
| 24 | + slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession) |
| 25 | + cliCommand = cdn.NewOriginRemoveCommand(slCommand) |
| 26 | + cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.") |
| 27 | + }) |
| 28 | + |
| 29 | + Describe("Cdn origin-remove", func() { |
| 30 | + Context("Cdn origin-remove, Invalid Usage", func() { |
| 31 | + It("Set command without id and path", func() { |
| 32 | + err := testhelpers.RunCobraCommand(cliCommand.Command) |
| 33 | + Expect(err).To(HaveOccurred()) |
| 34 | + Expect(err.Error()).To(ContainSubstring("Incorrect Usage: This command requires two argument")) |
| 35 | + }) |
| 36 | + }) |
| 37 | + |
| 38 | + Context("Cdn origin-remove, correct use", func() { |
| 39 | + It("return cdn origin-remove", func() { |
| 40 | + err := testhelpers.RunCobraCommand(cliCommand.Command, "123456", "/path/*") |
| 41 | + Expect(err).NotTo(HaveOccurred()) |
| 42 | + Expect(fakeUI.Outputs()).To(ContainSubstring("The origin")) |
| 43 | + Expect(fakeUI.Outputs()).To(ContainSubstring("was deleted.")) |
| 44 | + }) |
| 45 | + }) |
| 46 | + }) |
| 47 | +}) |
0 commit comments