Skip to content

Commit d509d03

Browse files
CLOUDP-285964: Clean up
1 parent a03356b commit d509d03

File tree

6 files changed

+53
-145
lines changed

6 files changed

+53
-145
lines changed

tools/ipa/__tests__/__helpers__/spectral.js

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

tools/ipa/__tests__/__helpers__/testRule.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ export default (ruleName, tests) => {
1515
const doc = testCase.document instanceof Document ? testCase.document : JSON.stringify(testCase.document);
1616
const allErrors = await s.run(doc);
1717

18-
const errors = allErrors.filter((e) => {
19-
if (testCase.errors[0]) {
20-
return e.code === testCase.errors[0].code;
21-
}
22-
return false;
23-
});
18+
const errors = getErrorsForRule(allErrors, ruleName);
2419

2520
expect(errors.length).toEqual(testCase.errors.length);
2621

@@ -36,8 +31,10 @@ export default (ruleName, tests) => {
3631

3732
async function createSpectral() {
3833
const s = new Spectral({ resolver: httpAndFileResolver });
39-
4034
s.setRuleset(await bundleAndLoadRuleset(rulesetPath, { fs, fetch }));
41-
4235
return s;
4336
}
37+
38+
function getErrorsForRule(errors, rule) {
39+
return errors.filter((e) => e.code === rule);
40+
}

tools/ipa/__tests__/descriptions.test.js

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

tools/ipa/__tests__/eachResourceHasGetMethod.test.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,82 @@ import { DiagnosticSeverity } from '@stoplight/types';
33

44
testRule('xgen-IPA-104-resource-has-GET', [
55
{
6-
name: 'valid standard method',
6+
name: 'valid methods',
77
document: {
88
paths: {
9-
'/example': {
9+
'/standard': {
1010
post: {},
1111
get: {},
1212
},
13-
'/example/{exampleId}': {
13+
'/standard/{exampleId}': {
1414
get: {},
1515
patch: {},
1616
delete: {},
1717
},
18+
'/custom': {
19+
post: {},
20+
get: {},
21+
},
22+
'/custom/{exampleId}': {
23+
get: {},
24+
patch: {},
25+
delete: {},
26+
},
27+
'/custom:method': {
28+
post: {},
29+
},
30+
'/singleton': {
31+
get: {},
32+
},
1833
},
1934
},
2035
errors: [],
2136
},
2237
{
23-
name: 'invalid standard method',
38+
name: 'invalid methods',
2439
document: {
2540
paths: {
26-
'/example': {
41+
'/standard': {
2742
post: {},
2843
get: {},
2944
},
30-
'/example/{exampleId}': {
45+
'/standard/{exampleId}': {
3146
patch: {},
3247
delete: {},
3348
},
49+
'/custom': {
50+
post: {},
51+
get: {},
52+
},
53+
'/custom/{exampleId}': {
54+
patch: {},
55+
delete: {},
56+
},
57+
'/custom:method': {
58+
post: {},
59+
},
60+
'/singleton': {
61+
patch: {},
62+
},
3463
},
3564
},
3665
errors: [
3766
{
3867
code: 'xgen-IPA-104-resource-has-GET',
3968
message: 'APIs must provide a get method for resources. http://go/ipa/117',
40-
path: ['paths', '/example'],
69+
path: ['paths', '/standard'],
70+
severity: DiagnosticSeverity.Warning,
71+
},
72+
{
73+
code: 'xgen-IPA-104-resource-has-GET',
74+
message: 'APIs must provide a get method for resources. http://go/ipa/117',
75+
path: ['paths', '/custom'],
76+
severity: DiagnosticSeverity.Warning,
77+
},
78+
{
79+
code: 'xgen-IPA-104-resource-has-GET',
80+
message: 'APIs must provide a get method for resources. http://go/ipa/117',
81+
path: ['paths', '/singleton'],
4182
severity: DiagnosticSeverity.Warning,
4283
},
4384
],

tools/ipa/ipa-spectral.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
extends:
22
- ./rulesets/IPA-104.yaml
3-
- ./rulesets/IPA-xxx.yaml

tools/ipa/rulesets/IPA-xxx.yaml

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

0 commit comments

Comments
 (0)