@@ -18,99 +18,6 @@ TEST_GROUP(tempodb) {
18
18
}
19
19
};
20
20
21
- TEST (tempodb, BulkIncrement_Request)
22
- {
23
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
24
- char *response_buffer = (char *)malloc (255 );
25
-
26
- tempodb_bulk_update *updates = (tempodb_bulk_update *)malloc (sizeof (tempodb_bulk_update) * 2 );
27
- tempodb_bulk_update update_by_id = { " series_1_id" , TEMPODB_ID, 1.1 };
28
- updates[0 ] = update_by_id;
29
- tempodb_bulk_update update_by_key = { " series_2_key" , TEMPODB_KEY, 2 };
30
- updates[1 ] = update_by_key;
31
-
32
- tempodb_bulk_increment (config, updates, 2 , response_buffer, 255 );
33
- STRCMP_CONTAINS (" POST /v1/increment" , last_request);
34
- STRCMP_CONTAINS (" {\" data\" :[{\" id\" :\" series_1_id\" ,\" v\" :1.100000},{\" key\" :\" series_2_key\" ,\" v\" :2.000000},]}" , last_request);
35
- free (response_buffer);
36
- free (updates);
37
- tempodb_destroy (config);
38
- }
39
-
40
- TEST (tempodb, BulkWrite_Request)
41
- {
42
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
43
- char *response_buffer = (char *)malloc (255 );
44
-
45
- tempodb_bulk_update *updates = (tempodb_bulk_update *)malloc (sizeof (tempodb_bulk_update) * 2 );
46
- tempodb_bulk_update update_by_id = { " series_1_id" , TEMPODB_ID, 1.1 };
47
- updates[0 ] = update_by_id;
48
- tempodb_bulk_update update_by_key = { " series_2_key" , TEMPODB_KEY, 2 };
49
- updates[1 ] = update_by_key;
50
-
51
- tempodb_bulk_write (config, updates, 2 , response_buffer, 255 );
52
- STRCMP_CONTAINS (" POST /v1/data" , last_request);
53
- STRCMP_CONTAINS (" {\" data\" :[{\" id\" :\" series_1_id\" ,\" v\" :1.100000},{\" key\" :\" series_2_key\" ,\" v\" :2.000000},]}" , last_request);
54
- free (response_buffer);
55
- free (updates);
56
- tempodb_destroy (config);
57
- }
58
-
59
- TEST (tempodb, IncrementByKey_Request)
60
- {
61
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
62
- char *response_buffer = (char *)malloc (255 );
63
- tempodb_increment_by_key (config, " series_key" , 10 , response_buffer, 255 );
64
- STRCMP_CONTAINS (" POST /v1/series/key/series_key/increment" , last_request);
65
- STRCMP_CONTAINS (" [{\" v\" :10.000000}]" , last_request);
66
- free (response_buffer);
67
- tempodb_destroy (config);
68
- }
69
-
70
- TEST (tempodb, IncrementById_Request)
71
- {
72
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
73
- char *response_buffer = (char *)malloc (255 );
74
- tempodb_increment_by_id (config, " series_id" , 10 , response_buffer, 255 );
75
- STRCMP_CONTAINS (" POST /v1/series/id/series_id/increment" , last_request);
76
- STRCMP_CONTAINS (" [{\" v\" :10.000000}]" , last_request);
77
- free (response_buffer);
78
- tempodb_destroy (config);
79
- }
80
-
81
- TEST (tempodb, WriteByKey_Request)
82
- {
83
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
84
- char *response_buffer = (char *)malloc (255 );
85
- tempodb_write_by_key (config, " series_key" , 10 , response_buffer, 255 );
86
- STRCMP_CONTAINS (" POST /v1/series/key/series_key/data" , last_request);
87
- STRCMP_CONTAINS (" [{\" v\" :10.000000}]" , last_request);
88
- free (response_buffer);
89
- tempodb_destroy (config);
90
- }
91
-
92
- TEST (tempodb, WriteById_Request)
93
- {
94
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
95
- char *response_buffer = (char *)malloc (255 );
96
- tempodb_write_by_id (config, " series_id" , 10 , response_buffer, 255 );
97
- STRCMP_CONTAINS (" POST /v1/series/id/series_id/data" , last_request);
98
- STRCMP_CONTAINS (" [{\" v\" :10.000000}]" , last_request);
99
- free (response_buffer);
100
- tempodb_destroy (config);
101
- }
102
-
103
- TEST (tempodb, Write_Response)
104
- {
105
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
106
- char *response_buffer = (char *)malloc (255 );
107
- set_test_response (" 200 OK" );
108
- tempodb_write_by_id (config, " series_id" , 10 , response_buffer, 255 );
109
- STRCMP_CONTAINS (" 200 OK" , response_buffer);
110
- free (response_buffer);
111
- tempodb_destroy (config);
112
- }
113
-
114
21
TEST (tempodb, Write_Response_Overrun)
115
22
{
116
23
tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
@@ -122,84 +29,3 @@ TEST(tempodb, Write_Response_Overrun)
122
29
free (response_buffer);
123
30
tempodb_destroy (config);
124
31
}
125
-
126
- TEST (tempodb, BuildQuery_IncludesHTTPVerbPathAndVersion)
127
- {
128
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
129
- char *buffer = (char *)malloc (255 );
130
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " " );
131
- STRCMP_CONTAINS (" GET /a/path HTTP/1.0" , buffer);
132
- free (buffer);
133
- tempodb_destroy (config);
134
- }
135
-
136
- TEST (tempodb, BuildQuery_DoesNotOverrun)
137
- {
138
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
139
- char *buffer = (char *)malloc (255 );
140
- memset (buffer, 1 , 255 );
141
- tempodb_build_query (config, buffer, 10 , " GET" , " /a/long/path" , " " );
142
- STRCMP_EQUAL (" GET /a/lo" , buffer);
143
- free (buffer);
144
- tempodb_destroy (config);
145
- }
146
-
147
- TEST (tempodb, BuildQuery_IncludesUserAgent)
148
- {
149
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
150
- char *buffer = (char *)malloc (255 );
151
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " " );
152
- STRCMP_CONTAINS (" \r\n User-Agent: tempodb-embedded-c/1.0.0\r\n " , buffer);
153
- free (buffer);
154
- tempodb_destroy (config);
155
- }
156
-
157
- TEST (tempodb, BuildQuery_IncludesHost)
158
- {
159
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
160
- char *buffer = (char *)malloc (255 );
161
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " " );
162
- STRCMP_CONTAINS (" \r\n Host: api.tempo-db.com\r\n " , buffer);
163
- free (buffer);
164
- tempodb_destroy (config);
165
- }
166
-
167
- TEST (tempodb, BuildQuery_IncludesPayload)
168
- {
169
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
170
- char *buffer = (char *)malloc (255 );
171
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " [{\" a\" :1,\" b\" :2}]" );
172
- STRCMP_CONTAINS (" \r\n\r\n [{\" a\" :1,\" b\" :2}]" , buffer);
173
- free (buffer);
174
- tempodb_destroy (config);
175
- }
176
-
177
- TEST (tempodb, BuildQuery_IncludesCredentials)
178
- {
179
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
180
- char *buffer = (char *)malloc (255 );
181
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " " );
182
- STRCMP_CONTAINS (" \r\n Authorization: Basic bXlfYWNjZXNzX2tleTpteV9zZWNyZXRfa2V5\r\n " , buffer);
183
- free (buffer);
184
- tempodb_destroy (config);
185
- }
186
-
187
- TEST (tempodb, BuildQuery_IncludesContentType)
188
- {
189
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
190
- char *buffer = (char *)malloc (255 );
191
- tempodb_build_query (config, buffer, 255 , " GET" , " /a/path" , " " );
192
- STRCMP_CONTAINS (" \r\n Content-Type: application/json\r\n " , buffer);
193
- free (buffer);
194
- tempodb_destroy (config);
195
- }
196
-
197
- TEST (tempodb, BuildQuery_IncludesContentLength)
198
- {
199
- tempodb_config *config = tempodb_create (" my_access_key" , " my_secret_key" );
200
- char *buffer = (char *)malloc (255 );
201
- tempodb_build_query (config, buffer, 255 , " POST" , " /a/path" , " 123456" );
202
- STRCMP_CONTAINS (" \r\n Content-Length: 6\r\n " , buffer);
203
- free (buffer);
204
- tempodb_destroy (config);
205
- }
0 commit comments