-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaccount_service_test.go
103 lines (98 loc) · 2.79 KB
/
account_service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package api
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("accountService", func() {
Describe("#ValidateAction", func() {
Context("action not set", func() {
It("Retuns false", func() {
client := New(Credential{}).account()
Expect(client.ValidateAction()).To(BeFalse())
})
})
Context("action set", func() {
It("Retuns true if Insert is set", func() {
client := New(Credential{}).account()
client.Insert()
Expect(client.ValidateAction()).To(BeTrue())
})
})
})
Describe("#Action", func() {
Context("Action not set", func() {
It("Returns a null string", func() {
client := New(Credential{}).account()
Expect(client.Action()).To(Equal(""))
})
})
Context("Action not set", func() {
It("returns action string", func() {
client := New(Credential{}).account()
client.Insert()
Expect(client.Action()).To(Equal("insert"))
})
})
})
Describe("#Insert", func() {
It("sets action as insert", func() {
client := New(Credential{}).account()
client.Insert()
Expect(client.Action()).To(Equal("insert"))
})
})
Describe("#Valid", func() {
var accountInfo AccountDetails
var credential Credential
BeforeEach(func() {
accountInfo = AccountDetails{
Name: "sarath",
}
credential = Credential{UserCredentials{AccessToken: "1212121"}, ClientCredentials{ClientID: "blah", ClientSecret: "ssas"}}
})
Context("Action is insert", func() {
It("Returns false if ClientSecret is not provided or is null string", func() {
credential.ClientSecret = ""
c := New(credential).account()
c.Setaccount(accountInfo)
c.Insert()
Expect(c.Valid()).To(BeFalse())
})
It("Returns false if ClientID is not provided or is null string", func() {
credential.ClientID = ""
c := New(credential).account()
c.Setaccount(accountInfo)
c.Insert()
Expect(c.Valid()).To(BeFalse())
})
It("Returns false if AccessToken is not provided or is null string", func() {
credential.AccessToken = ""
c := New(credential).account()
c.Setaccount(accountInfo)
c.Insert()
Expect(c.Valid()).To(BeFalse())
})
It("Returns false if Name is not provided or is null string", func() {
accountInfo.Name = ""
c := New(credential).account()
c.Setaccount(accountInfo)
c.Insert()
Expect(c.Valid()).To(BeFalse())
})
})
It("Returns false if Action is not set ", func() {
c := New(credential).account()
c.Setaccount(accountInfo)
Expect(c.Valid()).To(BeFalse())
})
})
Describe("#Setaccount", func() {
It("Set the Account Details", func() {
var account = AccountDetails{Name: "Sarath"}
client := New(Credential{}).account()
client.Setaccount(account)
Expect(client.account.Name).To(Equal("Sarath"))
Expect(client.account.Sid).To(Equal(""))
})
})
})