@@ -5,6 +5,7 @@ Execute (proompter#callback#channel#CompleteToHistory -- Handles well formated H
5
5
let separator = "\r\n"
6
6
7
7
let api_response = join([
8
+ \ 'HTTP/1.1 200 OK',
8
9
\ 'Server: SimpleHTTP/0.6 Python/3.12.6',
9
10
\ 'Date: Sat, 28 Sep 2024 23:29:00 GMT',
10
11
\ 'Content-Type: application/json',
@@ -56,6 +57,31 @@ Execute (proompter#callback#channel#CompleteToHistory -- Handles well formated H
56
57
AssertEqual state, expected_state
57
58
AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
58
59
60
+ Execute (proompter#callback#channel#CompleteToHistory -- Throws when status code is not in 200 range):
61
+ let separator = "\r\n"
62
+
63
+ let api_response = join([
64
+ \ 'HTTP/1.1 500 Internal Server Error',
65
+ \ 'Server: SimpleHTTP/0.6 Python/3.12.6',
66
+ \ ], separator)
67
+
68
+ let configurations = {
69
+ \ 'select': {
70
+ \ 'model_name': 'mistral',
71
+ \ },
72
+ \ }
73
+
74
+ let expected_configurations = deepcopy(configurations)
75
+
76
+ let state = { 'messages': [] }
77
+
78
+ let expected_state = { 'messages': [ ] }
79
+
80
+ AssertThrows call proompter#callback#channel#CompleteToHistory(g:api_response, g:configurations, g:state)
81
+
82
+ AssertEqual g:vader_exception, 'HTTP response not okay -> 500 Internal Server Error'
83
+ AssertEqual state, expected_state, 'Unexpected mutation of state'
84
+ AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
59
85
" }}}
60
86
""
61
87
@@ -65,6 +91,7 @@ Execute (proompter#callback#channel#StreamToMessages -- Handles JSON stream with
65
91
let separator = "\r\n"
66
92
67
93
let api_response = join([
94
+ \ 'HTTP/1.1 200 OK',
68
95
\ 'Server: SimpleHTTP/0.6 Python/3.12.6',
69
96
\ 'Date: Fri, 20 Sep 2024 23:25:06 GMT',
70
97
\ 'Content-Type: application/json',
@@ -140,6 +167,32 @@ Execute (proompter#callback#channel#StreamToMessages -- Handles JSON stream with
140
167
141
168
AssertEqual state, expected_state
142
169
AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
170
+
171
+ Execute (proompter#callback#channel#StreamToMessages -- Throws when status code is not in 200 range):
172
+ let separator = "\r\n"
173
+
174
+ let api_response = join([
175
+ \ 'HTTP/1.1 500 Internal Server Error',
176
+ \ 'Server: SimpleHTTP/0.6 Python/3.12.6',
177
+ \ ], separator)
178
+
179
+ let configurations = {
180
+ \ 'select': {
181
+ \ 'model_name': 'mistral',
182
+ \ },
183
+ \ }
184
+
185
+ let expected_configurations = deepcopy(configurations)
186
+
187
+ let state = { 'messages': [] }
188
+
189
+ let expected_state = { 'messages': [ ] }
190
+
191
+ AssertThrows call proompter#callback#channel#StreamToMessages(g:api_response, g:configurations, g:state)
192
+
193
+ AssertEqual g:vader_exception, 'HTTP response not okay -> 500 Internal Server Error'
194
+ AssertEqual state, expected_state, 'Unexpected mutation of state'
195
+ AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
143
196
" }}}
144
197
""
145
198
@@ -149,6 +202,7 @@ Execute (proompter#callback#channel#StreamToBuffer -- Handles JSON stream with o
149
202
let separator = "\r\n"
150
203
151
204
let api_response = join([
205
+ \ 'HTTP/1.1 200 OK',
152
206
\ 'Server: SimpleHTTP/0.6 Python/3.12.6',
153
207
\ 'Date: Fri, 20 Sep 2024 23:25:06 GMT',
154
208
\ 'Content-Type: application/json',
@@ -234,6 +288,7 @@ Execute(proompter#callback#channel#StreamToBuffer -- Handles JSON with newlines)
234
288
let separator = "\r\n"
235
289
236
290
let api_response = join([
291
+ \ 'HTTP/1.1 200 OK',
237
292
\ 'Server: SimpleHTTP/0.6 Python/3.12.6',
238
293
\ 'Date: Fri, 20 Sep 2024 23:25:06 GMT',
239
294
\ 'Content-Type: application/json',
@@ -297,6 +352,37 @@ Execute(proompter#callback#channel#StreamToBuffer -- Handles JSON with newlines)
297
352
AssertEqual state, expected_state
298
353
AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
299
354
AssertEqual getbufline(bufnr('[Vader-workbench]'), 0, '$')[-5:-3], split(expected_state.messages[-1].message.content, "\n")
355
+
356
+ Execute (proompter#callback#channel#StreamToBuffer -- Throws when status code is not in 200 range):
357
+ let separator = "\r\n"
358
+
359
+ let api_response = join([
360
+ \ 'HTTP/1.1 500 Internal Server Error',
361
+ \ 'Server: SimpleHTTP/0.6 Python/3.12.6',
362
+ \ ], separator)
363
+
364
+ let configurations = {
365
+ \ 'select': {
366
+ \ 'model_name': 'mistral',
367
+ \ },
368
+ \ }
369
+
370
+ let expected_configurations = deepcopy(configurations)
371
+
372
+ let state = { 'messages': [] }
373
+
374
+ let expected_state = { 'messages': [ ] }
375
+
376
+ AssertThrows call proompter#callback#channel#StreamToBuffer(
377
+ \ g:api_response,
378
+ \ g:configurations,
379
+ \ g:state,
380
+ \ '[Vader-workbench]',
381
+ \ )
382
+
383
+ AssertEqual g:vader_exception, 'HTTP response not okay -> 500 Internal Server Error'
384
+ AssertEqual state, expected_state, 'Unexpected mutation of state'
385
+ AssertEqual configurations, expected_configurations, 'Unexpected mutation of configurations'
300
386
" }}}
301
387
""
302
388
0 commit comments