Skip to content

Commit

Permalink
Ignore superseded operations in coverage reports. (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock authored Sep 16, 2024
1 parent 811a5c9 commit 8fe6a49
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
11 changes: 7 additions & 4 deletions tools/src/tester/TestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ export default class TestResults {

operations(): Operation[] {
if (this._operations !== undefined) return this._operations
this._operations = _.uniqWith(Object.entries(this._spec.paths()).flatMap(([path, path_item]) => {
return Object.values(path_item).map((method) => {
return { method: method.toUpperCase(), path }

this._operations = _.uniqWith(_.compact(Object.entries(this._spec.spec().paths).flatMap(([path, ops]) => {
return Object.entries(ops as Record<string, any>).map(([method, spec]) => {
if (spec['x-ignorable'] !== true) {
return { method: method.toUpperCase(), path }
}
})
}), isEqual)
})), isEqual)

return this._operations
}
Expand Down
4 changes: 2 additions & 2 deletions tools/src/tester/types/test.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Operation } from "./eval.types"
export interface SpecTestCoverage {
summary: {
total_operations_count: number
evaluated_operations_count: number,
evaluated_operations_count: number
evaluated_paths_pct: number
},
operations: Operation[],
operations: Operation[]
evaluated_operations: Operation[]
}
1 change: 1 addition & 0 deletions tools/tests/tester/MergedOpenApiSpec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('merged API spec', () => {
test('paths', () => {
expect(spec.paths()).toEqual({
'/_nodes/{id}': ['get', 'post'],
'/_superseded/nodes/{id}': ['get'],
'/cluster_manager': ['get', 'post'],
'/index': ['get'],
'/nodes': ['get']
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
$schema: should-be-ignored
$schema: should-be-ignored

/_superseded/nodes/{id}:
superseded_by: /_nodes/{id}
operations:
- GET

0 comments on commit 8fe6a49

Please sign in to comment.