@curl-runner/cli 1.16.0 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/ci-exit.test.ts +0 -216
- package/src/cli.ts +0 -1351
- package/src/commands/upgrade.ts +0 -262
- package/src/diff/baseline-manager.test.ts +0 -181
- package/src/diff/baseline-manager.ts +0 -266
- package/src/diff/diff-formatter.ts +0 -316
- package/src/diff/index.ts +0 -3
- package/src/diff/response-differ.test.ts +0 -330
- package/src/diff/response-differ.ts +0 -489
- package/src/executor/max-concurrency.test.ts +0 -139
- package/src/executor/profile-executor.test.ts +0 -132
- package/src/executor/profile-executor.ts +0 -167
- package/src/executor/request-executor.ts +0 -663
- package/src/parser/yaml.test.ts +0 -480
- package/src/parser/yaml.ts +0 -271
- package/src/snapshot/index.ts +0 -3
- package/src/snapshot/snapshot-differ.test.ts +0 -358
- package/src/snapshot/snapshot-differ.ts +0 -296
- package/src/snapshot/snapshot-formatter.ts +0 -170
- package/src/snapshot/snapshot-manager.test.ts +0 -204
- package/src/snapshot/snapshot-manager.ts +0 -342
- package/src/types/bun-yaml.d.ts +0 -11
- package/src/types/config.ts +0 -638
- package/src/utils/colors.ts +0 -30
- package/src/utils/condition-evaluator.test.ts +0 -415
- package/src/utils/condition-evaluator.ts +0 -327
- package/src/utils/curl-builder.test.ts +0 -165
- package/src/utils/curl-builder.ts +0 -209
- package/src/utils/installation-detector.test.ts +0 -52
- package/src/utils/installation-detector.ts +0 -123
- package/src/utils/logger.ts +0 -856
- package/src/utils/response-store.test.ts +0 -213
- package/src/utils/response-store.ts +0 -108
- package/src/utils/stats.test.ts +0 -161
- package/src/utils/stats.ts +0 -151
- package/src/utils/version-checker.ts +0 -158
- package/src/version.ts +0 -43
- package/src/watcher/file-watcher.test.ts +0 -186
- package/src/watcher/file-watcher.ts +0 -140
package/src/parser/yaml.test.ts
DELETED
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { YamlParser } from './yaml';
|
|
3
|
-
|
|
4
|
-
describe('YamlParser.interpolateVariables with store context', () => {
|
|
5
|
-
test('should resolve store variables', () => {
|
|
6
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
7
|
-
const obj = { url: 'https://api.example.com/users/${store.userId}' };
|
|
8
|
-
const variables = {};
|
|
9
|
-
const storeContext = { userId: '123' };
|
|
10
|
-
|
|
11
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
12
|
-
expect(result).toEqual({ url: 'https://api.example.com/users/123' });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('should resolve multiple store variables in one string', () => {
|
|
16
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
17
|
-
const obj = { url: 'https://api.example.com/users/${store.userId}/posts/${store.postId}' };
|
|
18
|
-
const variables = {};
|
|
19
|
-
const storeContext = { userId: '123', postId: '456' };
|
|
20
|
-
|
|
21
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
22
|
-
expect(result).toEqual({ url: 'https://api.example.com/users/123/posts/456' });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('should resolve store variables in nested objects', () => {
|
|
26
|
-
const obj = {
|
|
27
|
-
headers: {
|
|
28
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
29
|
-
Authorization: 'Bearer ${store.token}',
|
|
30
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
31
|
-
'X-User-Id': '${store.userId}',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
const variables = {};
|
|
35
|
-
const storeContext = { token: 'jwt-token', userId: '123' };
|
|
36
|
-
|
|
37
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
38
|
-
expect(result).toEqual({
|
|
39
|
-
headers: {
|
|
40
|
-
Authorization: 'Bearer jwt-token',
|
|
41
|
-
'X-User-Id': '123',
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('should resolve store variables in arrays', () => {
|
|
47
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
48
|
-
const obj = { ids: ['${store.id1}', '${store.id2}'] };
|
|
49
|
-
const variables = {};
|
|
50
|
-
const storeContext = { id1: '1', id2: '2' };
|
|
51
|
-
|
|
52
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
53
|
-
expect(result).toEqual({ ids: ['1', '2'] });
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should keep unresolved store variables as-is', () => {
|
|
57
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
58
|
-
const obj = { url: 'https://api.example.com/users/${store.missing}' };
|
|
59
|
-
const variables = {};
|
|
60
|
-
const storeContext = {};
|
|
61
|
-
|
|
62
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
63
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
64
|
-
expect(result).toEqual({ url: 'https://api.example.com/users/${store.missing}' });
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('should mix store variables with static variables', () => {
|
|
68
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
69
|
-
const obj = { url: '${BASE_URL}/users/${store.userId}' };
|
|
70
|
-
const variables = { BASE_URL: 'https://api.example.com' };
|
|
71
|
-
const storeContext = { userId: '123' };
|
|
72
|
-
|
|
73
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
74
|
-
expect(result).toEqual({ url: 'https://api.example.com/users/123' });
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('should work without store context (backwards compatibility)', () => {
|
|
78
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
79
|
-
const obj = { url: '${BASE_URL}/users' };
|
|
80
|
-
const variables = { BASE_URL: 'https://api.example.com' };
|
|
81
|
-
|
|
82
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
83
|
-
expect(result).toEqual({ url: 'https://api.example.com/users' });
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('should resolve single store variable as exact value', () => {
|
|
87
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
88
|
-
const obj = { userId: '${store.userId}' };
|
|
89
|
-
const variables = {};
|
|
90
|
-
const storeContext = { userId: '123' };
|
|
91
|
-
|
|
92
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
93
|
-
expect(result).toEqual({ userId: '123' });
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('should mix store variables with dynamic variables', () => {
|
|
97
|
-
const obj = {
|
|
98
|
-
headers: {
|
|
99
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
100
|
-
'X-Request-ID': '${UUID}',
|
|
101
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
102
|
-
Authorization: 'Bearer ${store.token}',
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
const variables = {};
|
|
106
|
-
const storeContext = { token: 'my-token' };
|
|
107
|
-
|
|
108
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext) as typeof obj;
|
|
109
|
-
// UUID should be a valid UUID string
|
|
110
|
-
expect(result.headers['X-Request-ID']).toMatch(
|
|
111
|
-
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
112
|
-
);
|
|
113
|
-
expect(result.headers.Authorization).toBe('Bearer my-token');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test('should resolve store variables in request body', () => {
|
|
117
|
-
const obj = {
|
|
118
|
-
body: {
|
|
119
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
120
|
-
userId: '${store.userId}',
|
|
121
|
-
name: 'Test User',
|
|
122
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${store.xxx} interpolation
|
|
123
|
-
parentId: '${store.parentId}',
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
const variables = {};
|
|
127
|
-
const storeContext = { userId: '123', parentId: '456' };
|
|
128
|
-
|
|
129
|
-
const result = YamlParser.interpolateVariables(obj, variables, storeContext);
|
|
130
|
-
expect(result).toEqual({
|
|
131
|
-
body: {
|
|
132
|
-
userId: '123',
|
|
133
|
-
name: 'Test User',
|
|
134
|
-
parentId: '456',
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe('YamlParser.resolveVariable', () => {
|
|
141
|
-
test('should resolve store variable', () => {
|
|
142
|
-
const storeContext = { userId: '123' };
|
|
143
|
-
const result = YamlParser.resolveVariable('store.userId', {}, storeContext);
|
|
144
|
-
expect(result).toBe('123');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('should return null for missing store variable', () => {
|
|
148
|
-
const storeContext = { other: 'value' };
|
|
149
|
-
const result = YamlParser.resolveVariable('store.missing', {}, storeContext);
|
|
150
|
-
expect(result).toBeNull();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('should resolve dynamic variable', () => {
|
|
154
|
-
const result = YamlParser.resolveVariable('UUID', {}, {});
|
|
155
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('should resolve static variable', () => {
|
|
159
|
-
const variables = { BASE_URL: 'https://api.example.com' };
|
|
160
|
-
const result = YamlParser.resolveVariable('BASE_URL', variables, {});
|
|
161
|
-
expect(result).toBe('https://api.example.com');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test('should return null for unknown variable', () => {
|
|
165
|
-
const result = YamlParser.resolveVariable('UNKNOWN', {}, {});
|
|
166
|
-
expect(result).toBeNull();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test('should prioritize store context over static variables', () => {
|
|
170
|
-
// This test ensures store.X prefix is properly handled
|
|
171
|
-
const variables = { 'store.userId': 'static-value' };
|
|
172
|
-
const storeContext = { userId: 'store-value' };
|
|
173
|
-
const result = YamlParser.resolveVariable('store.userId', variables, storeContext);
|
|
174
|
-
expect(result).toBe('store-value');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('YamlParser string transforms', () => {
|
|
179
|
-
test('should transform variable to uppercase with :upper', () => {
|
|
180
|
-
const variables = { ENV: 'production' };
|
|
181
|
-
const result = YamlParser.resolveVariable('ENV:upper', variables, {});
|
|
182
|
-
expect(result).toBe('PRODUCTION');
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('should transform variable to lowercase with :lower', () => {
|
|
186
|
-
const variables = { RESOURCE: 'USERS' };
|
|
187
|
-
const result = YamlParser.resolveVariable('RESOURCE:lower', variables, {});
|
|
188
|
-
expect(result).toBe('users');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('should return null for transform on missing variable', () => {
|
|
192
|
-
const result = YamlParser.resolveVariable('MISSING:upper', {}, {});
|
|
193
|
-
expect(result).toBeNull();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('should work with interpolateVariables for :upper transform', () => {
|
|
197
|
-
const obj = {
|
|
198
|
-
headers: {
|
|
199
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
200
|
-
'X-Environment': '${ENV:upper}',
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
const variables = { ENV: 'production' };
|
|
204
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
205
|
-
expect(result).toEqual({
|
|
206
|
-
headers: {
|
|
207
|
-
'X-Environment': 'PRODUCTION',
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
test('should work with interpolateVariables for :lower transform', () => {
|
|
213
|
-
const obj = {
|
|
214
|
-
headers: {
|
|
215
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
216
|
-
'X-Resource': '${RESOURCE:lower}',
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
const variables = { RESOURCE: 'USERS' };
|
|
220
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
221
|
-
expect(result).toEqual({
|
|
222
|
-
headers: {
|
|
223
|
-
'X-Resource': 'users',
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test('should mix transforms with regular variables', () => {
|
|
229
|
-
const obj = {
|
|
230
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
231
|
-
url: '${BASE_URL}/${RESOURCE:lower}',
|
|
232
|
-
headers: {
|
|
233
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
234
|
-
'X-Environment': '${ENV:upper}',
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
const variables = { BASE_URL: 'https://api.example.com', RESOURCE: 'Users', ENV: 'staging' };
|
|
238
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
239
|
-
expect(result).toEqual({
|
|
240
|
-
url: 'https://api.example.com/users',
|
|
241
|
-
headers: {
|
|
242
|
-
'X-Environment': 'STAGING',
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
test('should keep unresolved transforms as-is', () => {
|
|
248
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
249
|
-
const obj = { value: '${MISSING:upper}' };
|
|
250
|
-
const result = YamlParser.interpolateVariables(obj, {});
|
|
251
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing string transform
|
|
252
|
-
expect(result).toEqual({ value: '${MISSING:upper}' });
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
describe('YamlParser.resolveVariable with default values', () => {
|
|
257
|
-
test('should use default value when variable is not set', () => {
|
|
258
|
-
const result = YamlParser.resolveVariable('API_TIMEOUT:5000', {}, {});
|
|
259
|
-
expect(result).toBe('5000');
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
test('should use variable value when set, ignoring default', () => {
|
|
263
|
-
const variables = { API_TIMEOUT: '10000' };
|
|
264
|
-
const result = YamlParser.resolveVariable('API_TIMEOUT:5000', variables, {});
|
|
265
|
-
expect(result).toBe('10000');
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
test('should handle nested default with first variable set', () => {
|
|
269
|
-
const variables = { DATABASE_HOST: 'prod-db.example.com' };
|
|
270
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
271
|
-
const result = YamlParser.resolveVariable('DATABASE_HOST:${DB_HOST:localhost}', variables, {});
|
|
272
|
-
expect(result).toBe('prod-db.example.com');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
test('should handle nested default with second variable set', () => {
|
|
276
|
-
const variables = { DB_HOST: 'staging-db.example.com' };
|
|
277
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
278
|
-
const result = YamlParser.resolveVariable('DATABASE_HOST:${DB_HOST:localhost}', variables, {});
|
|
279
|
-
expect(result).toBe('staging-db.example.com');
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
test('should use final fallback when no variables are set', () => {
|
|
283
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
284
|
-
const result = YamlParser.resolveVariable('DATABASE_HOST:${DB_HOST:localhost}', {}, {});
|
|
285
|
-
expect(result).toBe('localhost');
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
test('should not confuse DATE: with default syntax', () => {
|
|
289
|
-
const result = YamlParser.resolveVariable('DATE:YYYY-MM-DD', {}, {});
|
|
290
|
-
// Should return a formatted date, not treat 'YYYY-MM-DD' as a default
|
|
291
|
-
expect(result).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
test('should not confuse TIME: with default syntax', () => {
|
|
295
|
-
const result = YamlParser.resolveVariable('TIME:HH:mm:ss', {}, {});
|
|
296
|
-
// Should return a formatted time, not treat 'HH:mm:ss' as a default
|
|
297
|
-
expect(result).toMatch(/^\d{2}:\d{2}:\d{2}$/);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
test('should handle default value with special characters', () => {
|
|
301
|
-
const result = YamlParser.resolveVariable('API_URL:https://api.example.com/v1', {}, {});
|
|
302
|
-
expect(result).toBe('https://api.example.com/v1');
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test('should handle empty default value', () => {
|
|
306
|
-
const result = YamlParser.resolveVariable('OPTIONAL:', {}, {});
|
|
307
|
-
expect(result).toBe('');
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
test('should use store variable when available before default', () => {
|
|
311
|
-
const storeContext = { token: 'stored-token' };
|
|
312
|
-
// Note: store variables have a different syntax (store.X), but we test
|
|
313
|
-
// that the default mechanism doesn't interfere
|
|
314
|
-
const result = YamlParser.resolveVariable('AUTH_TOKEN:default-token', {}, storeContext);
|
|
315
|
-
expect(result).toBe('default-token');
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
describe('YamlParser.interpolateVariables with default values', () => {
|
|
320
|
-
test('should interpolate variable with default in string', () => {
|
|
321
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
322
|
-
const obj = { timeout: '${API_TIMEOUT:5000}' };
|
|
323
|
-
const result = YamlParser.interpolateVariables(obj, {});
|
|
324
|
-
expect(result).toEqual({ timeout: '5000' });
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test('should interpolate variable with value set over default', () => {
|
|
328
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
329
|
-
const obj = { timeout: '${API_TIMEOUT:5000}' };
|
|
330
|
-
const variables = { API_TIMEOUT: '10000' };
|
|
331
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
332
|
-
expect(result).toEqual({ timeout: '10000' });
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
test('should handle multiple variables with defaults in one string', () => {
|
|
336
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
337
|
-
const obj = { url: '${BASE_URL:https://api.example.com}/${VERSION:v1}/users' };
|
|
338
|
-
const result = YamlParser.interpolateVariables(obj, {});
|
|
339
|
-
expect(result).toEqual({ url: 'https://api.example.com/v1/users' });
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
test('should mix defaults with regular variables', () => {
|
|
343
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
344
|
-
const obj = { url: '${BASE_URL}/api/${VERSION:v1}/users' };
|
|
345
|
-
const variables = { BASE_URL: 'https://prod.example.com' };
|
|
346
|
-
const result = YamlParser.interpolateVariables(obj, variables);
|
|
347
|
-
expect(result).toEqual({ url: 'https://prod.example.com/api/v1/users' });
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
test('should handle nested defaults in interpolation', () => {
|
|
351
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
352
|
-
const obj = { host: '${DATABASE_HOST:${DB_HOST:localhost}}' };
|
|
353
|
-
const result = YamlParser.interpolateVariables(obj, {});
|
|
354
|
-
expect(result).toEqual({ host: 'localhost' });
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
test('should preserve DATE: formatting syntax', () => {
|
|
358
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
359
|
-
const obj = { date: '${DATE:YYYY-MM-DD}' };
|
|
360
|
-
const result = YamlParser.interpolateVariables(obj, {}) as { date: string };
|
|
361
|
-
expect(result.date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
test('should preserve TIME: formatting syntax', () => {
|
|
365
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing variable interpolation
|
|
366
|
-
const obj = { time: '${TIME:HH:mm:ss}' };
|
|
367
|
-
const result = YamlParser.interpolateVariables(obj, {}) as { time: string };
|
|
368
|
-
expect(result.time).toMatch(/^\d{2}:\d{2}:\d{2}$/);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
describe('YamlParser.resolveDynamicVariable', () => {
|
|
373
|
-
test('should resolve UUID to a valid full UUID', () => {
|
|
374
|
-
const result = YamlParser.resolveDynamicVariable('UUID');
|
|
375
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
test('should resolve UUID:short to first 8 characters of a UUID', () => {
|
|
379
|
-
const result = YamlParser.resolveDynamicVariable('UUID:short');
|
|
380
|
-
expect(result).toMatch(/^[0-9a-f]{8}$/i);
|
|
381
|
-
expect(result).toHaveLength(8);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test('should resolve RANDOM:min-max to a number within range', () => {
|
|
385
|
-
const result = YamlParser.resolveDynamicVariable('RANDOM:1-100');
|
|
386
|
-
expect(result).not.toBeNull();
|
|
387
|
-
const num = Number(result);
|
|
388
|
-
expect(num).toBeGreaterThanOrEqual(1);
|
|
389
|
-
expect(num).toBeLessThanOrEqual(100);
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
test('should resolve RANDOM:min-max with large range', () => {
|
|
393
|
-
const result = YamlParser.resolveDynamicVariable('RANDOM:1-1000');
|
|
394
|
-
expect(result).not.toBeNull();
|
|
395
|
-
const num = Number(result);
|
|
396
|
-
expect(num).toBeGreaterThanOrEqual(1);
|
|
397
|
-
expect(num).toBeLessThanOrEqual(1000);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
test('should resolve RANDOM:min-max with same min and max', () => {
|
|
401
|
-
const result = YamlParser.resolveDynamicVariable('RANDOM:5-5');
|
|
402
|
-
expect(result).toBe('5');
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
test('should resolve RANDOM:string:length to alphanumeric string of correct length', () => {
|
|
406
|
-
const result = YamlParser.resolveDynamicVariable('RANDOM:string:10');
|
|
407
|
-
expect(result).not.toBeNull();
|
|
408
|
-
expect(result).toHaveLength(10);
|
|
409
|
-
expect(result).toMatch(/^[A-Za-z0-9]+$/);
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
test('should resolve RANDOM:string:length with different lengths', () => {
|
|
413
|
-
const result5 = YamlParser.resolveDynamicVariable('RANDOM:string:5');
|
|
414
|
-
const result20 = YamlParser.resolveDynamicVariable('RANDOM:string:20');
|
|
415
|
-
expect(result5).toHaveLength(5);
|
|
416
|
-
expect(result20).toHaveLength(20);
|
|
417
|
-
expect(result5).toMatch(/^[A-Za-z0-9]+$/);
|
|
418
|
-
expect(result20).toMatch(/^[A-Za-z0-9]+$/);
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
test('should resolve TIMESTAMP to a numeric string', () => {
|
|
422
|
-
const result = YamlParser.resolveDynamicVariable('TIMESTAMP');
|
|
423
|
-
expect(result).toMatch(/^\d+$/);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
test('should resolve CURRENT_TIME to a numeric string', () => {
|
|
427
|
-
const result = YamlParser.resolveDynamicVariable('CURRENT_TIME');
|
|
428
|
-
expect(result).toMatch(/^\d+$/);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
test('should return null for unknown dynamic variable', () => {
|
|
432
|
-
const result = YamlParser.resolveDynamicVariable('UNKNOWN');
|
|
433
|
-
expect(result).toBeNull();
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
describe('YamlParser.interpolateVariables with new dynamic variables', () => {
|
|
438
|
-
test('should interpolate UUID:short in objects', () => {
|
|
439
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${UUID:short} interpolation
|
|
440
|
-
const obj = { id: '${UUID:short}' };
|
|
441
|
-
const result = YamlParser.interpolateVariables(obj, {}) as typeof obj;
|
|
442
|
-
expect(result.id).toMatch(/^[0-9a-f]{8}$/i);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
test('should interpolate RANDOM:min-max in objects', () => {
|
|
446
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${RANDOM:x-y} interpolation
|
|
447
|
-
const obj = { value: '${RANDOM:1-100}' };
|
|
448
|
-
const result = YamlParser.interpolateVariables(obj, {}) as typeof obj;
|
|
449
|
-
const num = Number(result.value);
|
|
450
|
-
expect(num).toBeGreaterThanOrEqual(1);
|
|
451
|
-
expect(num).toBeLessThanOrEqual(100);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
test('should interpolate RANDOM:string:length in objects', () => {
|
|
455
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing ${RANDOM:string:n} interpolation
|
|
456
|
-
const obj = { token: '${RANDOM:string:16}' };
|
|
457
|
-
const result = YamlParser.interpolateVariables(obj, {}) as typeof obj;
|
|
458
|
-
expect(result.token).toHaveLength(16);
|
|
459
|
-
expect(result.token).toMatch(/^[A-Za-z0-9]+$/);
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
test('should interpolate multiple new dynamic variables in one object', () => {
|
|
463
|
-
const obj = {
|
|
464
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing dynamic variable interpolation
|
|
465
|
-
sessionId: '${UUID:short}',
|
|
466
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing dynamic variable interpolation
|
|
467
|
-
randomNum: '${RANDOM:1-1000}',
|
|
468
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: Testing dynamic variable interpolation
|
|
469
|
-
randomStr: '${RANDOM:string:10}',
|
|
470
|
-
};
|
|
471
|
-
const result = YamlParser.interpolateVariables(obj, {}) as typeof obj;
|
|
472
|
-
|
|
473
|
-
expect(result.sessionId).toMatch(/^[0-9a-f]{8}$/i);
|
|
474
|
-
const num = Number(result.randomNum);
|
|
475
|
-
expect(num).toBeGreaterThanOrEqual(1);
|
|
476
|
-
expect(num).toBeLessThanOrEqual(1000);
|
|
477
|
-
expect(result.randomStr).toHaveLength(10);
|
|
478
|
-
expect(result.randomStr).toMatch(/^[A-Za-z0-9]+$/);
|
|
479
|
-
});
|
|
480
|
-
});
|