Skip to content

Commit 8f347fe

Browse files
Ramkishor ChaladiRamkishor Chaladi
authored andcommitted
reset files to master version
1 parent ab51a4c commit 8f347fe

10 files changed

Lines changed: 89 additions & 71 deletions

File tree

plugin/commands/callapi/callapi.go

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package callapi
22

33
import (
44
"bytes"
5+
"encoding/json"
56
"fmt"
67
"strings"
78

@@ -96,62 +97,7 @@ func (cmd *CallAPICommand) Run(args []string) error {
9697
return nil
9798
}
9899

99-
// 1
100-
// var jsonMap []map[string]interface{}
101-
// err = json.Unmarshal([]byte(output), &jsonMap)
102-
// if err != nil {
103-
// fmt.Println("Error parsing JSON data:", err)
104-
// }
105-
// fmt.Println("JSON data:", jsonMap)
106-
107-
// keys := make([]int, 0, len(jsonMap))
108-
109-
// for _, dataMap := range jsonMap {
110-
// for _, value := range dataMap {
111-
// keys = append(keys, value)
112-
// }
113-
// }
114-
115-
// fmt.Println(jsonMap)
116-
// fmt.Println("Before Keys: \n", keys)
117-
118-
// sort.Sort(jsonMap)
119-
// sort.SliceStable(keys, func(i, j int) bool {
120-
// return keys[i] < keys[j]
121-
// })
122-
123-
// fmt.Println("After Keys: \n", keys)
124-
125-
//2
126-
// data := DataSlice{{"key1":4567,"key2":"def"},{"key1":1234,"key2":"abc"},}
127-
// type DataMap map[string]interface{}
128-
// type DataSlice []DataMap
129-
130-
// func (s DataSlice) Len() int{
131-
// return len(s)
132-
// }
133-
134-
// func (s DataSlice) Less(i, j int) bool {
135-
// val1, ok1 := s[i]["key1"].(int)
136-
// val2, ok2 := s[j]["key1"].(int)
137-
138-
// if !ok || !ok2 {
139-
// return false
140-
// }
141-
// return val1 < val2
142-
// }
143-
144-
// func (s DataSlice) Swap(i, j int){
145-
// s[i], s[j] = s[j], s[i]
146-
// }
147-
148-
// fmt.Println("\nBefore Sorting: ")
149-
150-
// sort.Sort(data)
151-
152-
// fmt.Println("\nAfter Sorting: ")
153-
154-
// err = json.Indent(&out, output, "", "\t")
100+
err = json.Indent(&out, output, "", "\t")
155101
if err != nil {
156102
_, err := cmd.UI.Writer().Write(output)
157103
if err != nil {

plugin/commands/cdn/origin_add_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var _ = Describe("Cdn origin add", func() {
7777

7878
Context("Cdn origin add, correct use", func() {
7979
It("return cdn origin add", func() {
80-
err := testhelpers.RunCobraCommand(cliCommand.Command, "123456789", "--origin", "123.123.123.123", "--path", "/example/videos/", "--http", "80", "--origin-type", "storage", "--bucket-name", "bucketName", "--file-extensions", "jpg")
80+
err := testhelpers.RunCobraCommand(cliCommand.Command, "123456789", "--origin", "123.123.123.123","--path", "/example/videos/", "--http", "80", "--origin-type", "storage", "--bucket-name", "bucketName", "--file-extensions", "jpg")
8181
Expect(err).NotTo(HaveOccurred())
8282
Expect(fakeUI.Outputs()).To(ContainSubstring("CDN Unique ID"))
8383
Expect(fakeUI.Outputs()).To(ContainSubstring("354034879028850"))
@@ -95,7 +95,7 @@ var _ = Describe("Cdn origin add", func() {
9595
Expect(fakeUI.Outputs()).To(ContainSubstring("RUNNING"))
9696
})
9797
It("return cdn in format json", func() {
98-
err := testhelpers.RunCobraCommand(cliCommand.Command, "123456789", "--origin", "123.123.123.123", "--path", "/example/videos/", "--http", "80", "--output", "json")
98+
err := testhelpers.RunCobraCommand(cliCommand.Command, "123456789", "--origin", "123.123.123.123","--path", "/example/videos/", "--http", "80", "--output", "json")
9999
Expect(err).NotTo(HaveOccurred())
100100
Expect(fakeUI.Outputs()).To(ContainSubstring(`"Name": "CDN Unique ID",`))
101101
Expect(fakeUI.Outputs()).To(ContainSubstring(`"Value": "354034879028850"`))

plugin/commands/image/detail_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var _ = Describe("Image detail", func() {
8383
Id: sl.Int(1234),
8484
AccountReferences: []datatypes.Virtual_Guest_Block_Device_Template_Group_Accounts{
8585
{
86-
AccountId: sl.Int(654),
86+
AccountId: sl.Int(654),
8787
CreateDate: sl.Time(created),
8888
},
8989
},

plugin/commands/meta/meta_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package meta_test
22

33
import (
4-
"fmt"
54
"testing"
5+
"fmt"
66

77
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
88
. "github.com/onsi/ginkgo"
@@ -21,10 +21,10 @@ func TestManagers(t *testing.T) {
2121

2222
var _ = Describe("Metadata list Metadata", func() {
2323
var (
24-
fakeUI *terminal.FakeUI
25-
cliCommand *meta.MetaCommand
26-
fakeSession *session.Session
27-
slCommand *metadata.SoftlayerCommand
24+
fakeUI *terminal.FakeUI
25+
cliCommand *meta.MetaCommand
26+
fakeSession *session.Session
27+
slCommand *metadata.SoftlayerCommand
2828
// fakeManager *testhelpers.FakeMetadataManager
2929
)
3030
BeforeEach(func() {
@@ -116,7 +116,7 @@ var _ = Describe("Metadata list Metadata", func() {
116116
It("return tags", func() {
117117
err := testhelpers.RunCobraCommand(cliCommand.Command, "tags")
118118
Expect(err).NotTo(HaveOccurred())
119-
fmt.Println("tagss:", fakeUI.Outputs())
119+
fmt.Println("tagss:",fakeUI.Outputs())
120120
Expect(fakeUI.Outputs()).To(ContainSubstring(`"testTags"`))
121121
})
122122
It("return user data", func() {

plugin/commands/subnet/route_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package subnet_test
22

33
import (
44
"errors"
5-
65
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
76
. "github.com/onsi/ginkgo"
87
. "github.com/onsi/gomega"

plugin/commands/user/edit_permission_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
77
. "github.com/onsi/ginkgo"
88
. "github.com/onsi/gomega"
9-
"github.com/softlayer/softlayer-go/datatypes"
109
"github.com/softlayer/softlayer-go/session"
10+
"github.com/softlayer/softlayer-go/datatypes"
1111

1212
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/user"
1313
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package user_test
2+
3+
import (
4+
"errors"
5+
6+
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
7+
. "github.com/onsi/ginkgo"
8+
. "github.com/onsi/gomega"
9+
"github.com/softlayer/softlayer-go/datatypes"
10+
"github.com/softlayer/softlayer-go/session"
11+
"github.com/softlayer/softlayer-go/sl"
12+
13+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/user"
14+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
15+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers"
16+
)
17+
18+
var _ = Describe("user vpn-enable", func() {
19+
var (
20+
fakeUI *terminal.FakeUI
21+
cliCommand *user.VpnEnableCommand
22+
fakeSession *session.Session
23+
slCommand *metadata.SoftlayerCommand
24+
fakeUserManager *testhelpers.FakeUserManager
25+
)
26+
BeforeEach(func() {
27+
fakeUI = terminal.NewFakeUI()
28+
fakeSession = testhelpers.NewFakeSoftlayerSession([]string{})
29+
fakeUserManager = new(testhelpers.FakeUserManager)
30+
slCommand = metadata.NewSoftlayerCommand(fakeUI, fakeSession)
31+
cliCommand = user.NewVpnEnableCommand(slCommand)
32+
cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.")
33+
cliCommand.UserManager = fakeUserManager
34+
35+
testUser = datatypes.User_Customer{
36+
SslVpnAllowedFlag: sl.Bool(true),
37+
}
38+
})
39+
40+
Describe("user vpn-enable", func() {
41+
42+
Context("Return error", func() {
43+
It("Set command without Argument", func() {
44+
err := testhelpers.RunCobraCommand(cliCommand.Command)
45+
Expect(err).To(HaveOccurred())
46+
Expect(err.Error()).To(ContainSubstring("Incorrect Usage: This command requires one argument."))
47+
})
48+
49+
It("Set command with an invalid user Id", func() {
50+
err := testhelpers.RunCobraCommand(cliCommand.Command, "abcde")
51+
Expect(err).To(HaveOccurred())
52+
Expect(err.Error()).To(ContainSubstring("Invalid input for 'User ID'. It must be a positive integer."))
53+
})
54+
})
55+
56+
Context("Account cancel-item, softlayer errors", func() {
57+
It("Set command with unknow item ID", func() {
58+
fakeUserManager.EditUserReturns(true, errors.New("SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '123'. (HTTP 404)"))
59+
err := testhelpers.RunCobraCommand(cliCommand.Command, "123")
60+
Expect(err).To(HaveOccurred())
61+
Expect(err.Error()).To(ContainSubstring("SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '123'. (HTTP 404)"))
62+
})
63+
})
64+
65+
Context("Return no error", func() {
66+
BeforeEach(func() {
67+
fakeUserManager.EditUserReturns(true, nil)
68+
})
69+
It("enable", func() {
70+
err := testhelpers.RunCobraCommand(cliCommand.Command, "111111")
71+
Expect(err).NotTo(HaveOccurred())
72+
Expect(fakeUI.Outputs()).To(ContainSubstring("OK"))
73+
})
74+
})
75+
})
76+
})

plugin/commands/virtual/authorize_storage_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package virtual_test
22

33
import (
44
"errors"
5-
65
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
76
. "github.com/onsi/ginkgo"
87
. "github.com/onsi/gomega"

plugin/commands/virtual/bandwidth_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package virtual_test
22

33
import (
4-
"time"
5-
64
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
75
. "github.com/onsi/ginkgo"
86
. "github.com/onsi/gomega"
7+
"time"
98

109
"github.com/softlayer/softlayer-go/datatypes"
1110
"github.com/softlayer/softlayer-go/session"

plugin/commands/virtual/reload_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package virtual_test
22

33
import (
44
"errors"
5-
65
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
76
. "github.com/onsi/ginkgo"
87
. "github.com/onsi/gomega"

0 commit comments

Comments
 (0)