Skip to content

Commit d5a2d5c

Browse files
author
Sophia Marie Terry
committed
IPA 107 tests for overrides
1 parent 7aa9c17 commit d5a2d5c

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,79 @@ testRule('xgen-IPA-107-valid-operation-id', [
7979
},
8080
],
8181
},
82+
{
83+
name: 'valid methods with valid overrides',
84+
document: {
85+
paths: {
86+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule': {
87+
patch: {
88+
operationId: 'updateGroupClusterBackupSchedule',
89+
'x-xgen-operation-id-override': 'updateBackupSchedule',
90+
},
91+
},
92+
},
93+
},
94+
errors: [],
95+
},
96+
{
97+
name: 'valid methods with invalid overrides',
98+
document: {
99+
paths: {
100+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule': {
101+
patch: {
102+
operationId: 'updateGroupClusterBackupSchedule',
103+
'x-xgen-operation-id-override': 'updateScheduleBackupMissing',
104+
},
105+
},
106+
},
107+
},
108+
errors: [
109+
{
110+
code: 'xgen-IPA-107-valid-operation-id',
111+
message:
112+
"The operation ID override must only contain nouns from the operation ID 'updateGroupClusterBackupSchedule'. ",
113+
path: [
114+
'paths',
115+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule',
116+
'patch',
117+
'x-xgen-operation-id-override',
118+
],
119+
severity: DiagnosticSeverity.Warning,
120+
},
121+
{
122+
code: 'xgen-IPA-107-valid-operation-id',
123+
message: "The operation ID override must end with the noun 'Schedule'. ",
124+
path: [
125+
'paths',
126+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule',
127+
'patch',
128+
'x-xgen-operation-id-override',
129+
],
130+
severity: DiagnosticSeverity.Warning,
131+
},
132+
],
133+
},
134+
{
135+
name: 'valid method with verb overrides',
136+
document: {
137+
paths: {
138+
'/api/atlas/v2/groups/{groupId}/serverless': {
139+
patch: {
140+
operationId: 'updateGroupServerlessInstance',
141+
'x-xgen-method-verb-override': { verb: 'updateInstance', customMethod: false },
142+
'x-xgen-operation-id-override': 'updateServerlessInstance',
143+
},
144+
},
145+
},
146+
},
147+
errors: [],
148+
},
82149
{
83150
name: 'invalid methods with exceptions',
84151
document: {
85152
paths: {
86153
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': {
87-
post: {
154+
put: {
88155
operationId: 'updateRollingIndex',
89156
'x-xgen-IPA-exception': {
90157
'xgen-IPA-107-valid-operation-id': 'Reason',

0 commit comments

Comments
 (0)