From 6b8cb63ed3d5c1470a073503e588e0277a50c78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 3 Dec 2025 13:47:00 +0100 Subject: [PATCH] invocation: interop testing in the same style as for delegation --- .../{fixtures_test.go => interop_test.go} | 21 ++++++++----------- .../interop.ipldsch} | 0 ...vocations.json => interop_invocation.json} | 0 3 files changed, 9 insertions(+), 12 deletions(-) rename token/invocation/{fixtures_test.go => interop_test.go} (88%) rename token/invocation/{fixtures.ipldsch => testdata/interop.ipldsch} (100%) rename token/invocation/testdata/{invocations.json => interop_invocation.json} (100%) diff --git a/token/invocation/fixtures_test.go b/token/invocation/interop_test.go similarity index 88% rename from token/invocation/fixtures_test.go rename to token/invocation/interop_test.go index a402e8c..cc22079 100644 --- a/token/invocation/fixtures_test.go +++ b/token/invocation/interop_test.go @@ -3,7 +3,6 @@ package invocation_test import ( _ "embed" "fmt" - "os" "testing" "github.com/ipfs/go-cid" @@ -12,12 +11,18 @@ import ( "github.com/ipld/go-ipld-prime/codec/dagjson" "github.com/ipld/go-ipld-prime/schema" "github.com/stretchr/testify/require" + "github.com/ucan-wg/go-ucan/token/delegation" "github.com/ucan-wg/go-ucan/token/internal/envelope" "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 func fixturesType(t *testing.T) schema.Type { @@ -45,17 +50,9 @@ type FixturesModel struct { Invalid []VectorModel } -type NamedError interface { - error - Name() string -} - -func TestFixtures(t *testing.T) { - fixturesFile, err := os.Open("./testdata/invocations.json") - require.NoError(t, err) - +func TestInterop(t *testing.T) { 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) for _, vector := range fixtures.Valid { diff --git a/token/invocation/fixtures.ipldsch b/token/invocation/testdata/interop.ipldsch similarity index 100% rename from token/invocation/fixtures.ipldsch rename to token/invocation/testdata/interop.ipldsch diff --git a/token/invocation/testdata/invocations.json b/token/invocation/testdata/interop_invocation.json similarity index 100% rename from token/invocation/testdata/invocations.json rename to token/invocation/testdata/interop_invocation.json