Skip to content

Commit

Permalink
Add doc comments, add print descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe committed Apr 3, 2024
1 parent c4a3b6d commit 26ff1c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dids/didjwk/didjwk_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package didjwk_test

import (
"fmt"
"testing"

"github.com/alecthomas/assert/v2"
Expand Down Expand Up @@ -40,11 +41,13 @@ func TestVector_Resolve(t *testing.T) {
testVectors, err :=
web5go.ReadTestVector[string, didcore.ResolutionResult]("../../web5-spec/test-vectors/did_jwk/resolve.json")
assert.NoError(t, err)
fmt.Println("Running test vectors: ", testVectors.Description)

resolver := &didjwk.Resolver{}

for _, vector := range testVectors.Vectors {
t.Run(vector.Description, func(t *testing.T) {
fmt.Println("Running test vector: ", vector.Description)
result, err := resolver.Resolve(vector.Input)

if vector.Errors {
Expand Down
3 changes: 3 additions & 0 deletions web5-spec-test-vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import (
"os"
)

// TestVectors are JSON files which are tested against to ensure interop with the specification
type TestVectors[T, U any] struct {
Description string `json:"description"`
Vectors []TestVector[T, U] `json:"vectors"`
}

// TestVector is an individual test vector case
type TestVector[T, U any] struct {
Description string `json:"description"`
Input T `json:"input"`
Output U `json:"output"`
Errors bool `json:"errors"`
}

// ReadTestVector is for reading the vector at the given path
func ReadTestVector[T, U any](path string) (TestVectors[T, U], error) {
data, err := os.ReadFile(path)
if err != nil {
Expand Down

0 comments on commit 26ff1c4

Please sign in to comment.