Skip to content

Commit

Permalink
update readme with example
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro-neal committed Dec 14, 2023
1 parent 42e12e5 commit b42e3d0
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions web5-test-vectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,84 @@ The structure of a `vector` object is designed to fulfill two conditions:
* In Rust, the error handling would pivot on matching `Result.Err` rather than `Result.Ok`.

Should `errors` be set to `true`, the `output` field may optionally be used to include expected error messages.

## Creating New Test Vector

### Step 1: Create New Test Vector

Check failure on line 52 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:52 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 1: Create New Test Vector"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md

Check failure on line 52 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:52 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 1: Create New Test Vector"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md
1. Navigate to the GitHub repository: https://github.com/TBD54566975/sdk-development/tree/main/web5-test-vectors

Check failure on line 53 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:53 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Navigate to the GitHub repo..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

Check failure on line 53 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

web5-test-vectors/README.md:53:39 MD034/no-bare-urls Bare URL used [Context: "https://github.com/TBD54566975..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md034.md

Check failure on line 53 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:53 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Navigate to the GitHub repo..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

Check failure on line 53 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Bare URL used

web5-test-vectors/README.md:53:39 MD034/no-bare-urls Bare URL used [Context: "https://github.com/TBD54566975..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md034.md

2. Create a new folder and JSON file with the structure example_feature/hello_world.json.

3. Populate the JSON file as follows:

```json
{
"description": "vector example",
"vectors": [
{
"description": "this is an example",
"input": "hello world",
"output": "hello world"
}
]
}
```

### Step 2: Copy JSON to Local Test-Vectors Directory

Check failure on line 72 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:72 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 2: Copy JSON to Local Test-Vectors Directory"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md

Check failure on line 72 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:72 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 2: Copy JSON to Local Test-Vectors Directory"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md
1. Copy the hello_world.json file from example_feature directory.

Check failure on line 73 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:73 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Copy the hello_world.json f..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

Check failure on line 73 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:73 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. Copy the hello_world.json f..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

2. Place the copied file into the top level test-vectors directory of both web5-kt and web5-js projects.


Check failure on line 77 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

web5-test-vectors/README.md:77 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md012.md

Check failure on line 77 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

web5-test-vectors/README.md:77 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md012.md
### Step 3: Create Unit Test in web5-kt

Check failure on line 78 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:78 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 3: Create Unit Test in web5-kt"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md

Check failure on line 78 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

web5-test-vectors/README.md:78 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Step 3: Create Unit Test in web5-kt"] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md022.md
1. In the web5-kt project, create a new unit test class.

Check failure on line 79 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:79 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. In the web5-kt project, cre..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

Check failure on line 79 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:79 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "1. In the web5-kt project, cre..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

2. Name the class following the given pattern:

Check failure on line 81 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:81 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "2. Name the class following th..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md

Check failure on line 81 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

web5-test-vectors/README.md:81 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "2. Name the class following th..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md032.md
* Prefix: Web5TestVectors

Check failure on line 82 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

web5-test-vectors/README.md:82:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md007.md

Check failure on line 82 in web5-test-vectors/README.md

View workflow job for this annotation

GitHub Actions / lint

Unordered list indentation

web5-test-vectors/README.md:82:1 MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md007.md
* Middle: Convert example_feature to ExampleFeature (capitalize words and remove underscores)
* Suffix: Test

Combined: Web5TestVectorsExampleFeatureTest

3. Implement the class and test method as follows:

```kt
class Web5TestVectorsExampleFeatureTest {
@Test
fun hello_world() {
val testVectors = mapper.readValue(File("../test-vectors/example_feature/hello_world.json"), typeRef)
assertEquals(testVectors.vectors[0].input, testVectors.vectors[0].output)
}
}
```

### Step 4: Create Unit Test in web5-js
1. In the web5-js project, create a new unit test class.

2. Name the class following the given pattern:
* Prefix: Web5TestVectors
* Middle: Convert example_feature to ExampleFeature (capitalize words and remove underscores)
* Suffix: Spec

Combined: Web5TestVectorsExampleFeatureSpec

3. Implement the class and test method as follows:

```javascript
import ExampleFeatureHelloWorldSpecJson from '../../../test-vectors/example_feature/hello_world.json' assert { type: 'json' };

describe('Web5TestVectorsExampleFeatureSpec', () => {
it('hello_world', async () => {
const vectors = ExampleFeatureHelloWorldSpecJson.vectors;
expect(vectors[0].input).to.equal(vectors[0].output)
});
});
```


### Step 5: Completion

* Once the above steps are completed, the sdk-development repository will automatically detect the new test vectors.
* The system will indicate whether the test passes or fails with a checkmark or an 'x'.

Your new test vector system is now set up and ready for use!

0 comments on commit b42e3d0

Please sign in to comment.