Skip to content

Commit

Permalink
# path.basename
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong committed May 28, 2024
1 parent 4bedf1f commit 8ece8c1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 4 deletions.
84 changes: 84 additions & 0 deletions tests/indices/index_lifecycle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
$schema: ../../json_schemas/test_story.schema.yaml

skip: false
description: This story tests all endpoints relevant the lifecycle of an index, from creation to deletion.
epilogues:
- path: /books,movies,games
method: DELETE
ignore_errors: false
chapters:
- synopsis: Create an index named `books` with mappings and settings.
path: /{index}
method: PUT
parameters:
index: books
request_body:
payload:
mappings:
properties:
name:
type: keyword
age:
type: integer
settings:
number_of_shards: 5
number_of_replicas: 2
response:
status: 200

- synopsis: Create an index named `games` with default settings,
path: /{index}
method: PUT
parameters:
index: games
response:
status: 200

- synopsis: Check if the index `books` exists. It should.
path: /{index}
method: HEAD
parameters:
index: books
response:
status: 200

- synopsis: Check if the index `movies` exists. It should not.
path: /{index}
method: HEAD
parameters:
index: movies
response:
status: 404

- synopsis: Retrieve the mappings and settings of the `books` and `games` indices.
path: /{index}
method: GET
parameters:
index: books,games
flat_settings: true
response:
status: 200

- synopsis: Close the `books` index.
path: /{index}/_close
method: POST
parameters:
index: books
response:
status: 200

- synopsis: Open the `books` index.
path: /{index}/_open
method: POST
parameters:
index: books
response:
status: 200

- synopsis: Delete the `books` and `games` indices.
path: /{index}
method: DELETE
parameters:
index: books,games
response:
status: 200
8 changes: 4 additions & 4 deletions tools/src/tester/TestsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { read_yaml } from '../../helpers'
import { type Result, type StoryEvaluation } from './types/eval.types'
import ResultsDisplayer from './ResultsDisplayer'
import SharedResources from './SharedResources'
import path from 'path'
import { resolve, basename } from 'path'

export default class TestsRunner {
path: string // Path to a story file or a directory containing story files
ignored_results: Set<Result> // Chapter results to ignore when displaying results

constructor (spec: OpenAPIV3.Document, test_path: string, ignored_results: Set<Result>) {
this.path = path.resolve(test_path)
constructor (spec: OpenAPIV3.Document, path: string, ignored_results: Set<Result>) {
this.path = resolve(path)
this.ignored_results = ignored_results

// TODO: Grab server URL from environment variable and add authentication.
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class TestsRunner {
if (fs.statSync(path).isFile()) {
const story: Story = read_yaml(path)
return [{
display_path: next_prefix === '' ? (path.split('/').reverse()[0]) : next_prefix,
display_path: next_prefix === '' ? basename(path) : next_prefix,
full_path: path,
story
}]
Expand Down

0 comments on commit 8ece8c1

Please sign in to comment.