Debian Codegraph @

fastly/sumologic_test.go

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 package fastly
2
3 import "testing"
4
5 func TestClient_Sumologics(t *testing.T) {
6 t.Parallel()
7
8 var err error
9 var tv *Version
10 record(t, "sumologics/version", func(c *Client) {
11 tv = testVersion(t, c)
12 })
13
14 // Create
15 var s *Sumologic
16 record(t, "sumologics/create", func(c *Client) {
17 s, err = c.CreateSumologic(&CreateSumologicInput{
18 Service: testServiceID,
19 Version: tv.Number,
20 Name: "test-sumologic",
21 URL: "https://foo.sumologic.com",
22 Format: "format",
23 FormatVersion: 1,
24 MessageType: "classic",
25 Placement: "waf_debug",
26 })
27 })
28 if err != nil {
29 t.Fatal(err)
30 }
31
32 // Ensure deleted
33 defer func() {
34 record(t, "sumologics/cleanup", func(c *Client) {
35 c.DeleteSumologic(&DeleteSumologicInput{
36 Service: testServiceID,
37 Version: tv.Number,
38 Name: "test-sumologic",
39 })
40
41 c.DeleteSumologic(&DeleteSumologicInput{
42 Service: testServiceID,
43 Version: tv.Number,
44 Name: "new-test-sumologic",
45 })
46 })
47 }()
48
49 if s.Name != "test-sumologic" {
50 t.Errorf("bad name: %q", s.Name)
51 }
52 if s.URL != "https://foo.sumologic.com" {
53 t.Errorf("bad url: %q", s.URL)
54 }
55 if s.Format != "format" {
56 t.Errorf("bad format: %q", s.Format)
57 }
58 if s.FormatVersion != 1 {
59 t.Errorf("bad format version: %q", s.FormatVersion)
60 }
61 if s.MessageType != "classic" {
62 t.Errorf("bad message type: %q", s.MessageType)
63 }
64 if s.Placement != "waf_debug" {
65 t.Errorf("bad placement: %q", s.Placement)
66 }
67
68 // List
69 var ss []*Sumologic
70 record(t, "sumologics/list", func(c *Client) {
71 ss, err = c.ListSumologics(&ListSumologicsInput{
72 Service: testServiceID,
73 Version: tv.Number,
74 })
75 })
76 if err != nil {
77 t.Fatal(err)
78 }
79 if len(ss) < 1 {
80 t.Errorf("bad sumologics: %v", ss)
81 }
82
83 // Get
84 var ns *Sumologic
85 record(t, "sumologics/get", func(c *Client) {
86 ns, err = c.GetSumologic(&GetSumologicInput{
87 Service: testServiceID,
88 Version: tv.Number,
89 Name: "test-sumologic",
90 })
91 })
92 if err != nil {
93 t.Fatal(err)
94 }
95 if s.Name != ns.Name {
96 t.Errorf("bad name: %q", s.Name)
97 }
98 if s.URL != ns.URL {
99 t.Errorf("bad url: %q", s.URL)
100 }
101 if s.Format != ns.Format {
102 t.Errorf("bad format: %q", s.Format)
103 }
104 if s.FormatVersion != ns.FormatVersion {
105 t.Errorf("bad format version: %q", s.FormatVersion)
106 }
107 if s.MessageType != ns.MessageType {
108 t.Errorf("bad message type: %q", s.MessageType)
109 }
110 if s.Placement != ns.Placement {
111 t.Errorf("bad placement: %q", s.Placement)
112 }
113
114 // Update
115 var us *Sumologic
116 record(t, "sumologics/update", func(c *Client) {
117 us, err = c.UpdateSumologic(&UpdateSumologicInput{
118 Service: testServiceID,
119 Version: tv.Number,
120 Name: "test-sumologic",
121 NewName: "new-test-sumologic",
122 })
123 })
124 if err != nil {
125 t.Fatal(err)
126 }
127 if us.Name != "new-test-sumologic" {
128 t.Errorf("bad name: %q", us.Name)
129 }
130
131 // Delete
132 record(t, "sumologics/delete", func(c *Client) {
133 err = c.DeleteSumologic(&DeleteSumologicInput{
134 Service: testServiceID,
135 Version: tv.Number,
136 Name: "new-test-sumologic",
137 })
138 })
139 if err != nil {
140 t.Fatal(err)
141 }
142 }
143
144 func TestClient_ListSumologics_validation(t *testing.T) {
145 var err error
146 _, err = testClient.ListSumologics(&ListSumologicsInput{
147 Service: "",
148 })
149 if err != ErrMissingService {
150 t.Errorf("bad error: %s", err)
151 }
152
153 _, err = testClient.ListSumologics(&ListSumologicsInput{
154 Service: "foo",
155 Version: 0,
156 })
157 if err != ErrMissingVersion {
158 t.Errorf("bad error: %s", err)
159 }
160 }
161
162 func TestClient_CreateSumologic_validation(t *testing.T) {
163 var err error
164 _, err = testClient.CreateSumologic(&CreateSumologicInput{
165 Service: "",
166 })
167 if err != ErrMissingService {
168 t.Errorf("bad error: %s", err)
169 }
170
171 _, err = testClient.CreateSumologic(&CreateSumologicInput{
172 Service: "foo",
173 Version: 0,
174 })
175 if err != ErrMissingVersion {
176 t.Errorf("bad error: %s", err)
177 }
178 }
179
180 func TestClient_GetSumologic_validation(t *testing.T) {
181 var err error
182 _, err = testClient.GetSumologic(&GetSumologicInput{
183 Service: "",
184 })
185 if err != ErrMissingService {
186 t.Errorf("bad error: %s", err)
187 }
188
189 _, err = testClient.GetSumologic(&GetSumologicInput{
190 Service: "foo",
191 Version: 0,
192 })
193 if err != ErrMissingVersion {
194 t.Errorf("bad error: %s", err)
195 }
196
197 _, err = testClient.GetSumologic(&GetSumologicInput{
198 Service: "foo",
199 Version: 1,
200 Name: "",
201 })
202 if err != ErrMissingName {
203 t.Errorf("bad error: %s", err)
204 }
205 }
206
207 func TestClient_UpdateSumologic_validation(t *testing.T) {
208 var err error
209 _, err = testClient.UpdateSumologic(&UpdateSumologicInput{
210 Service: "",
211 })
212 if err != ErrMissingService {
213 t.Errorf("bad error: %s", err)
214 }
215
216 _, err = testClient.UpdateSumologic(&UpdateSumologicInput{
217 Service: "foo",
218 Version: 0,
219 })
220 if err != ErrMissingVersion {
221 t.Errorf("bad error: %s", err)
222 }
223
224 _, err = testClient.UpdateSumologic(&UpdateSumologicInput{
225 Service: "foo",
226 Version: 1,
227 Name: "",
228 })
229 if err != ErrMissingName {
230 t.Errorf("bad error: %s", err)
231 }
232 }
233
234 func TestClient_DeleteSumologic_validation(t *testing.T) {
235 var err error
236 err = testClient.DeleteSumologic(&DeleteSumologicInput{
237 Service: "",
238 })
239 if err != ErrMissingService {
240 t.Errorf("bad error: %s", err)
241 }
242
243 err = testClient.DeleteSumologic(&DeleteSumologicInput{
244 Service: "foo",
245 Version: 0,
246 })
247 if err != ErrMissingVersion {
248 t.Errorf("bad error: %s", err)
249 }
250
251 err = testClient.DeleteSumologic(&DeleteSumologicInput{
252 Service: "foo",
253 Version: 1,
254 Name: "",
255 })
256 if err != ErrMissingName {
257 t.Errorf("bad error: %s", err)
258 }
259 }