-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Theo Truong <theotr@amazon.com>
- Loading branch information
Showing
29 changed files
with
789 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { create_shared_resources, load_actual_evaluation, load_expected_evaluation } from './helpers' | ||
import { read_yaml } from '../../helpers' | ||
import { type OpenAPIV3 } from 'openapi-types' | ||
|
||
const spec = read_yaml('tools/tests/tester/fixtures/specs/indices_excerpt.yaml') | ||
create_shared_resources(spec as OpenAPIV3.Document) | ||
|
||
test('passed', async () => { | ||
const actual = await load_actual_evaluation('passed') | ||
const expected = await load_expected_evaluation('passed') | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('skipped', async () => { | ||
const actual = await load_actual_evaluation('skipped') | ||
const expected = await load_expected_evaluation('skipped') | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('failed/not_found', async () => { | ||
const actual = await load_actual_evaluation('failed/not_found') | ||
const expected = await load_expected_evaluation('failed/not_found') | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('failed/invalid_data', async () => { | ||
const actual = await load_actual_evaluation('failed/invalid_data') | ||
const expected = await load_expected_evaluation('failed/invalid_data') | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('error/prologue_error', async () => { | ||
const actual = await load_actual_evaluation('error/prologue_error') | ||
const expected = await load_expected_evaluation('error/prologue_error') | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('error/chapter_error', async () => { | ||
const actual = await load_actual_evaluation('error/chapter_error') | ||
const expected = await load_expected_evaluation('error/chapter_error') | ||
expect(actual).toEqual(expected) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { read_yaml } from '../../helpers' | ||
import TestsRunner from '../../src/tester/TestsRunner' | ||
import { type OpenAPIV3 } from 'openapi-types' | ||
import { load_expected_evaluation, scrub_errors } from './helpers' | ||
|
||
test('stories folder', async () => { | ||
// The password must match the one specified in .github/workflows/test-spec.yml | ||
process.env.OPENSEARCH_PASSWORD = 'myStrongPassword123!' | ||
const spec = read_yaml('tools/tests/tester/fixtures/specs/indices_excerpt.yaml') | ||
const runner = new TestsRunner(spec as OpenAPIV3.Document, 'tools/tests/tester/fixtures/stories', {}) | ||
const actual_evaluations = await runner.run(true) as any[] | ||
for (const evaluation of actual_evaluations) scrub_errors(evaluation) | ||
for (const evaluation of actual_evaluations) { | ||
expect(evaluation.full_path.endsWith(evaluation.display_path)).toBeTruthy() | ||
delete evaluation.full_path | ||
} | ||
|
||
const skipped = await load_expected_evaluation('skipped', true) | ||
const passed = await load_expected_evaluation('passed', true) | ||
const not_found = await load_expected_evaluation('failed/not_found', true) | ||
const invalid_data = await load_expected_evaluation('failed/invalid_data', true) | ||
const chapter_error = await load_expected_evaluation('error/chapter_error', true) | ||
const prologue_error = await load_expected_evaluation('error/prologue_error', true) | ||
|
||
const expected_evaluations = [passed, skipped, chapter_error, prologue_error, invalid_data, not_found] | ||
expect(actual_evaluations).toEqual(expected_evaluations) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
import * as ansi from '../../src/tester/Ansi' | ||
|
||
test('b', async () => { | ||
test('b', () => { | ||
expect(ansi.b('xyz')).toEqual('\x1b[1mxyz\x1b[0m') | ||
}) | ||
|
||
test('i', async () => { | ||
test('i', () => { | ||
expect(ansi.i('xyz')).toEqual('\x1b[3mxyz\x1b[0m') | ||
}) | ||
|
||
test.todo('padding') | ||
test.todo('green') | ||
test.todo('red') | ||
test.todo('yellow') | ||
test.todo('cyan') | ||
test.todo('gray') | ||
test.todo('magenta') | ||
test('padding', () => { | ||
expect(ansi.padding('xyz', 10)).toEqual('xyz ') | ||
expect(ansi.padding('xyz', 10, 2)).toEqual(' xyz ') | ||
expect(ansi.padding('xyz', 10, 8)).toEqual(' xyz ') | ||
expect(ansi.padding('xyz', 2)).toEqual('xyz') | ||
}) | ||
|
||
test('green', () => { | ||
expect(ansi.green('xyz')).toEqual('\x1b[32mxyz\x1b[0m') | ||
}) | ||
|
||
test('red', () => { | ||
expect(ansi.red('xyz')).toEqual('\x1b[31mxyz\x1b[0m') | ||
}) | ||
|
||
test('yellow', () => { | ||
expect(ansi.yellow('xyz')).toEqual('\x1b[33mxyz\x1b[0m') | ||
}) | ||
|
||
test('cyan', () => { | ||
expect(ansi.cyan('xyz')).toEqual('\x1b[36mxyz\x1b[0m') | ||
}) | ||
|
||
test('gray', () => { | ||
expect(ansi.gray('xyz')).toEqual('\x1b[90mxyz\x1b[0m') | ||
}) | ||
|
||
test('magenta', () => { | ||
expect(ansi.magenta('xyz')).toEqual('\x1b[35mxyz\x1b[0m') | ||
}) |
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
tools/tests/tester/fixtures/evals/error/chapter_error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
display_path: error/chapter_error.yaml | ||
full_path: tools/tests/tester/fixtures/stories/error/chapter_error.yaml | ||
|
||
result: ERROR | ||
description: This story should failed due to missing info in the spec. | ||
|
||
prologues: | ||
- title: PUT /books | ||
overall: | ||
result: PASSED | ||
|
||
chapters: | ||
- title: This chapter should fail. | ||
overall: | ||
result: FAILED | ||
message: Operation "GET /{index}/settings" not found in the spec. | ||
- title: This chapter show throw an error. | ||
overall: | ||
result: ERROR | ||
request: | ||
parameters: {} | ||
request_body: | ||
result: PASSED | ||
response: | ||
status: | ||
result: ERROR | ||
message: 'Expected status 200, but received 404: application/json. no such index | ||
[undefined]' | ||
error: Request failed with status code 404 | ||
payload: | ||
result: SKIPPED | ||
- title: This chapter should be skipped. | ||
overall: | ||
result: SKIPPED | ||
|
||
epilogues: | ||
- title: DELETE /books | ||
overall: | ||
result: PASSED |
Oops, something went wrong.