Skip to content
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

Commit 711a553

Browse files
committed
merged apid and is libsonnet
1 parent bd533a6 commit 711a553

File tree

6 files changed

+109
-239
lines changed

6 files changed

+109
-239
lines changed

tests/passing/apid/apid.libsonnet

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,114 @@
1+
local SHORTHAND_MATCHER_PREFIX = '$$shorthand_matcher$$';
2+
3+
4+
local any_matcher() =
5+
{
6+
'$$matcher_type$$': 'any',
7+
};
8+
9+
local string_matcher(string, case_sensitive=true) =
10+
{
11+
'$$matcher_type$$': 'string',
12+
'$$matcher_params$$': {
13+
value: string,
14+
case_sensitive: case_sensitive,
15+
},
16+
};
17+
18+
local regex_matcher(regex) =
19+
{
20+
'$$matcher_type$$': 'regex',
21+
'$$matcher_params$$': regex,
22+
};
23+
24+
local int_matcher(int) =
25+
{
26+
'$$matcher_type$$': 'int',
27+
'$$matcher_params$$': int,
28+
};
29+
30+
local float_matcher(float) =
31+
{
32+
'$$matcher_type$$': 'float',
33+
'$$matcher_params$$': float,
34+
};
35+
36+
local json_matcher(json, subset=false) =
37+
{
38+
'$$matcher_type$$': 'json',
39+
'$$matcher_params$$': {
40+
value: json,
41+
subset: subset,
42+
},
43+
};
44+
45+
local array_matcher(array, subset=false) =
46+
{
47+
'$$matcher_type$$': 'array',
48+
'$$matcher_params$$': {
49+
value: array,
50+
subset: subset,
51+
},
52+
};
53+
54+
local len_matcher(len) =
55+
{
56+
'$$matcher_type$$': 'len',
57+
'$$matcher_params$$': len,
58+
};
59+
60+
local and_matcher(matchers) =
61+
{
62+
'$$matcher_type$$': 'and',
63+
'$$matcher_params$$': matchers,
64+
};
65+
66+
local or_matcher(matchers) =
67+
{
68+
'$$matcher_type$$': 'or',
69+
'$$matcher_params$$': matchers,
70+
};
71+
72+
local range_matcher(from, to) =
73+
{
74+
'$$matcher_type$$': 'range',
75+
'$$matcher_params$$': {
76+
from: from,
77+
to: to,
78+
},
79+
};
80+
81+
local type_matcher(type) =
82+
{
83+
'$$matcher_type$$': 'type::%s' % type,
84+
'$$matcher_params$$': null,
85+
};
86+
187
{
288
spec(steps):: std.manifestJson(
389
{
490
steps: steps,
591
},
692
),
93+
94+
type: {
95+
int():: type_matcher('int'),
96+
float():: type_matcher('float'),
97+
string():: type_matcher('string'),
98+
object():: type_matcher('object'),
99+
array():: type_matcher('array'),
100+
},
101+
102+
key(matcher):: '%s%s' % [SHORTHAND_MATCHER_PREFIX, std.manifestJsonEx(matcher, '')],
103+
any():: any_matcher(),
104+
regex(regex):: regex_matcher(regex),
105+
string(string, case_sensitive=true):: string_matcher(string, case_sensitive),
106+
int(int):: int_matcher(int),
107+
float(float):: float_matcher(float),
108+
json(json, subset=false):: json_matcher(json, subset),
109+
array(array, subset=false):: array_matcher(array, subset),
110+
len(len):: len_matcher(len),
111+
and(matchers):: and_matcher(matchers),
112+
or(matchers):: or_matcher(matchers),
113+
range(from, to):: range_matcher(from, to),
7114
}

tests/passing/apid/is.libsonnet

Lines changed: 0 additions & 108 deletions
This file was deleted.

tests/passing/body_pass.jsonnet

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
local apid = import 'apid/apid.libsonnet';
2-
local _ = import 'apid/is.libsonnet';
1+
local _ = import 'apid/apid.libsonnet';
32

43
local vars = import 'vars.libsonnet';
54

@@ -31,7 +30,7 @@ local steps(method, body, expected) = [
3130
];
3231

3332
{
34-
['float-%s-%s-%s' % [method, 'body', expected]]: apid.spec(
33+
['float-%s-%s-%s' % [method, 'body', expected]]: _.spec(
3534
steps=steps(method, body, expected),
3635
)
3736
for method in ['POST', 'PUT', 'PATCH', 'DELETE']

tests/passing/headers_pass.jsonnet

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/passing/lib_pass.jsonnet

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/passing/status_codes_pass.jsonnet

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)