Skip to content

Commit

Permalink
Undo semver satisfies changes.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 13, 2024
1 parent 7c50fef commit 936fb9c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tools/src/merger/OpenApiVersionExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class OpenApiVersionExtractor {

constructor(source_spec: OpenAPIV3.Document, target_version?: string, target_distribution?: string, logger: Logger = new Logger()) {
this._source_spec = source_spec
this._target_version = target_version !== undefined ? (semver.coerce(target_version)?.toString() ?? target_version) : target_version
this._target_version = semver.coerce(target_version)?.toString() ?? target_version
this._target_distribution = target_distribution
this._logger = logger
this._spec = undefined
Expand Down
8 changes: 2 additions & 6 deletions tools/src/tester/StoryEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class StoryEvaluator {
}

async evaluate({ story, display_path, full_path }: StoryFile, version?: string, distribution?: string, dry_run: boolean = false): Promise<StoryEvaluation> {
if (version !== undefined && story.version !== undefined && !StoryEvaluator.#semver_satisfies(version, story.version)) {
if (version !== undefined && story.version !== undefined && !semver.satisfies(version, story.version)) {
return {
result: Result.SKIPPED,
display_path,
Expand Down Expand Up @@ -92,7 +92,7 @@ export default class StoryEvaluator {
if (dry_run) {
const title = chapter.synopsis || `${chapter.method} ${chapter.path}`
evaluations.push({ title, overall: { result: Result.SKIPPED, message: 'Dry Run', error: undefined } })
} else if (version != undefined && chapter.version !== undefined && !StoryEvaluator.#semver_satisfies(version, chapter.version)) {
} else if (version != undefined && chapter.version !== undefined && semver.satisfies(version, chapter.version)) {
const title = chapter.synopsis || `${chapter.method} ${chapter.path}`
evaluations.push({ title, overall: { result: Result.SKIPPED, message: `Skipped because version ${version} does not satisfy ${chapter.version}.`, error: undefined } })
} else if (distribution != undefined && chapter.distributions !== undefined && !chapter.distributions.includes(distribution)) {
Expand Down Expand Up @@ -236,8 +236,4 @@ export default class StoryEvaluator {
static #failed_evaluation(title: string, message: string): ChapterEvaluation {
return { title, overall: { result: Result.FAILED, message } }
}

static #semver_satisfies(version: string, range: string): boolean {
return _.every(range.split(','), (portion) => semver.satisfies(version, portion))
}
}
2 changes: 1 addition & 1 deletion tools/tests/tester/fixtures/evals/passed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ chapters:
- title: This GET /_cat/health should be skipped (> 2.999.0).
overall:
result: SKIPPED
message: Skipped because version 2.16.0 does not satisfy >= 2.999.0.
message: Skipped because version 2.16.0 does not satisfy > 2.999.0.
- title: This GET /_cat/health should not be skipped (> 2.0, < 10).
overall:
result: PASSED
Expand Down

0 comments on commit 936fb9c

Please sign in to comment.