|
1 | 1 | package account_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "strings" |
| 5 | + "fmt" |
4 | 6 | "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal" |
5 | 7 | . "github.com/onsi/ginkgo/v2" |
6 | 8 | . "github.com/onsi/gomega" |
@@ -55,25 +57,24 @@ var _ = Describe("Account list InvoiceDetail", func() { |
55 | 57 | It("return account invoice detail", func() { |
56 | 58 | err := testhelpers.RunCobraCommand(cliCommand.Command, "123") |
57 | 59 | Expect(err).NotTo(HaveOccurred()) |
58 | | - Expect(fakeUI.Outputs()).To(ContainSubstring("Item Id Category Description Single Monthly Create Date Location")) |
59 | | - Expect(fakeUI.Outputs()).To(ContainSubstring("123456789 Server Dual Intel Xeon Silver 4210 (20 Cores, 2.20 GHz) (test-gpu.softlayer-community-f... 22.59 35.26 2022-04-04 mex01")) |
60 | | - Expect(fakeUI.Outputs()).To(ContainSubstring("123456789123 server Dual E5-2690 v3 (12 Cores, 2.60 GHz) (test-vs.support2.com) 23.81 36.04 2022-04-04 ams01")) |
| 60 | + Expect(fakeUI.Outputs()).To(ContainSubstring("Item Id Category Description Single Monthly Create Date Location")) |
| 61 | + Expect(fakeUI.Outputs()).To(ContainSubstring("123456789 Server Dual Intel Xeon Silver 4210 (20 Cores, 2.20 GHz) (test-gpu.softlayer-community-f... 22.59 35.26 2022-04-04 mex01")) |
| 62 | + Expect(fakeUI.Outputs()).To(ContainSubstring("123456789123 server Dual E5-2690 v3 (12 Cores, 2.60 GHz) (test-vs.support2.com) 23.81 36.04 2022-04-04 ams01")) |
| 63 | + Expect(fakeUI.Outputs()).To(ContainSubstring("1531470246 Endurance Endurance Storage (SL-1234566789) 0.00 0.00 2020-05-04 ams01")) |
61 | 64 | }) |
62 | 65 | It("return account invoice detail with additionals details", func() { |
63 | 66 | err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "--details") |
64 | 67 | Expect(err).NotTo(HaveOccurred()) |
65 | | - Expect(fakeUI.Outputs()).To(Equal( |
66 | | -`Item Id Category Description Single Monthly Create Date Location |
67 | | -123456789 Server Dual Intel Xeon Silver 4210 (20 Cores, 2.20 GHz) (test-gpu.softlayer-community-f... 22.59 35.26 2022-04-04 mex01 |
68 | | ->>> Server Dual Intel Xeon Silver 4210 (20 Cores, 2.20 GHz) (test-gpu.softlayer-community-f... 10.23 20.34 --- --- |
69 | | ->>> Second Processor Intel Xeon (12 Cores, 2.40 GHz) 5.24 6.12 --- --- |
70 | | ->>> Operating System Virtual (up to 1Gbps) 7.12 8.79 --- --- |
71 | | -123456789123 server Dual E5-2690 v3 (12 Cores, 2.60 GHz) (test-vs.support2.com) 23.81 36.04 2022-04-04 ams01 |
72 | | ->>> server Dual E5-2690 v3 (12 Cores, 2.60 GHz) (test-vs.support2.com) 11.23 21.12 --- --- |
73 | | ->>> Second Processor Intel Xeon (12 Cores, 2.40 GHz) 5.35 6.23 --- --- |
74 | | ->>> Operating System Virtual (up to 1Gbps) 7.23 8.68 --- --- |
75 | | -`)) |
76 | | - }) |
| 68 | + // Unsure if removing whitespace from the output makes it easier or harder to test. Looks ugly here, but |
| 69 | + // at least it won't break if formatting slightly changes. |
| 70 | + output := strings.Split(strings.ReplaceAll(fakeUI.Outputs(), " ", ""), "\n") |
| 71 | + fmt.Printf(fakeUI.Outputs()) |
| 72 | + Expect(output[1]).To(Equal(`123456789ServerDualIntelXeonSilver4210(20Cores,2.20GHz)(test-gpu.softlayer-community-f...22.5935.262022-04-04mex01`)) |
| 73 | + Expect(output[2]).To(Equal(`>>>ServerDualIntelXeonSilver4210(20Cores,2.20GHz)(test-gpu.softlayer-community-f...10.2320.34------`)) |
| 74 | + Expect(output[3]).To(Equal(`>>>SecondProcessorIntelXeon(12Cores,2.40GHz)5.246.12------`)) |
| 75 | + // https://github.ibm.com/SoftLayer/softlayer-cli/issues/904 |
| 76 | + Expect(output[9]).To(Equal(`1531470246EnduranceEnduranceStorage(SL-1234566789)0.000.002020-05-04ams01`)) |
| 77 | + }) |
77 | 78 | It("return account invoice detail in format json", func() { |
78 | 79 | err := testhelpers.RunCobraCommand(cliCommand.Command, "123", "--output", "json") |
79 | 80 | Expect(err).NotTo(HaveOccurred()) |
|
0 commit comments