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 0dea683 commit 7097d88
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ This repository includes several OpenAPI Specification Extensions to fill in any
- `x-distributions-included`: Contains a list of distributions known to include the API.
- `x-distributions-excluded`: Contains a list of distributions known to exclude the API.

Use `opensearch.org` for the official distribution in `x-distributions-*`, `amazon-opensearch` for Amazon Managed OpenSearch, and `amazon-serverless` for Amazon OpenSearch Serverless.
Use `opensearch.org` for the official distribution in `x-distributions-*`, `amazon-managed` for Amazon Managed OpenSearch, and `amazon-serverless` for Amazon OpenSearch Serverless.

## Writing Spec Tests

Expand Down
2 changes: 1 addition & 1 deletion tools/src/_utils/semver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import * as semver from 'semver'

export function coerce(version?: string): undefined | string {
if (version == undefined) return undefined
if (version === undefined) return undefined
return semver.coerce(version)?.toString() ?? version
}

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/src/tester/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class TestRunner {
const results: StoryEvaluations = { evaluations: [] }

if (!dry_run) {
if (distribution === 'aoss') {
if (distribution === 'amazon-serverless') {
// TODO: Fetch OpenSearch version when Amazon Serverless OpenSearch supports multiple.
version = '2.1'
} else {
Expand Down
4 changes: 2 additions & 2 deletions tools/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export interface OperationSpec extends OpenAPIV3.OperationObject {
'x-version-deprecated'?: string
'x-deprecation-message'?: string
'x-ignorable'?: boolean
'x-distributions-included'?: string
'x-distributions-excluded'?: string
'x-distributions-included'?: string[]
'x-distributions-excluded'?: string[]

parameters?: OpenAPIV3.ReferenceObject[]
requestBody?: OpenAPIV3.ReferenceObject
Expand Down

0 comments on commit 7097d88

Please sign in to comment.