invocation: interop testing in the same style as for delegation
This commit is contained in:
@@ -3,7 +3,6 @@ package invocation_test
|
|||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@@ -12,12 +11,18 @@ import (
|
|||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
||||||
"github.com/ipld/go-ipld-prime/schema"
|
"github.com/ipld/go-ipld-prime/schema"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/token/delegation"
|
"github.com/ucan-wg/go-ucan/token/delegation"
|
||||||
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
"github.com/ucan-wg/go-ucan/token/invocation"
|
"github.com/ucan-wg/go-ucan/token/invocation"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed fixtures.ipldsch
|
// This comes from https://github.com/ucan-wg/spec/blob/main/fixtures/1.0.0/invocation.json
|
||||||
|
//
|
||||||
|
//go:embed testdata/interop_invocation.json
|
||||||
|
var interopInvocation []byte
|
||||||
|
|
||||||
|
//go:embed testdata/interop.ipldsch
|
||||||
var schemaBytes []byte
|
var schemaBytes []byte
|
||||||
|
|
||||||
func fixturesType(t *testing.T) schema.Type {
|
func fixturesType(t *testing.T) schema.Type {
|
||||||
@@ -45,17 +50,9 @@ type FixturesModel struct {
|
|||||||
Invalid []VectorModel
|
Invalid []VectorModel
|
||||||
}
|
}
|
||||||
|
|
||||||
type NamedError interface {
|
func TestInterop(t *testing.T) {
|
||||||
error
|
|
||||||
Name() string
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFixtures(t *testing.T) {
|
|
||||||
fixturesFile, err := os.Open("./testdata/invocations.json")
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
var fixtures FixturesModel
|
var fixtures FixturesModel
|
||||||
_, err = ipld.UnmarshalStreaming(fixturesFile, dagjson.Decode, &fixtures, fixturesType(t))
|
_, err := ipld.Unmarshal(interopInvocation, dagjson.Decode, &fixtures, fixturesType(t))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, vector := range fixtures.Valid {
|
for _, vector := range fixtures.Valid {
|
||||||
Reference in New Issue
Block a user