Commit 91923f8a authored by Eric Myhre's avatar Eric Myhre

Drop vestigial tests.

These were apparently never used, or their users got churned under
at some point and I failed to clean these up at the same time.

It's a good idea to have tests that are agnostic to codegen vs
runtime type semantics implementations... but at this point we should
reengage with that by just extracting the stuff currently in the
codegen package's tests, because it's much more comprehensive and
also almost entirely abstracted already (it just happens to be in the
wrong place in the file/package hierarchy for no particular reason).
parent 32d5243a
// The `schema/tests` package contains behavioral tests for type-constrained
// Node implementations -- meant to work with either codegenerated Nodes OR
// with the runtime schema.TypedNode wrappers, checking for the same behavior on each.
package tests
package tests
import (
"testing"
. "github.com/warpfork/go-wish"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/schema"
)
func TestFoo(t *testing.T, newNb func(typ schema.Type) ipld.NodeBuilder) {
tString := schema.SpawnString("String")
tStroct := schema.SpawnStruct("Stroct",
[]schema.StructField{
schema.SpawnStructField("f1", tString, false, false),
schema.SpawnStructField("f2", tString, true, false),
schema.SpawnStructField("f3", tString, true, true),
schema.SpawnStructField("f4", tString, false, false),
},
schema.StructRepresentation_Map{},
)
var n1 ipld.Node
t.Run("test building", func(t *testing.T) {
t.Run("all values valid", func(t *testing.T) {
nb := newNb(tStroct)
ma, err := nb.BeginMap(3)
Wish(t, err, ShouldEqual, nil)
// Set 'f1' to a valid string.
va, err := ma.AssembleEntry("f1")
Wish(t, err, ShouldEqual, nil)
Wish(t, va.AssignString("asdf"), ShouldEqual, nil)
// Skip setting 'f2' -- it's optional.
// Set 'f3' to null. Nulls aren't typed.
va, err = ma.AssembleEntry("f3")
Wish(t, err, ShouldEqual, nil)
Wish(t, va.AssignNull(), ShouldEqual, nil)
// Set 'f4' to a valid string.
va, err = ma.AssembleEntry("f4")
Wish(t, err, ShouldEqual, nil)
Wish(t, va.AssignString("qwer"), ShouldEqual, nil)
Wish(t, ma.Finish(), ShouldEqual, nil)
n1 = nb.Build()
})
t.Run("wrong type rejected", func(t *testing.T) {
})
t.Run("invalid key rejected", func(t *testing.T) {
})
t.Run("missing nonoptional rejected", func(t *testing.T) {
})
t.Run("null nonnullable rejected", func(t *testing.T) {
})
})
t.Run("reading", func(t *testing.T) {
t.Run("regular fields", func(t *testing.T) {
v, err := n1.LookupByString("f1")
Wish(t, err, ShouldEqual, nil)
nb := newNb(tString)
Require(t, nb.AssignString("asdf"), ShouldEqual, nil)
v2 := nb.Build()
Wish(t, v, ShouldEqual, v2)
})
t.Run("optional absent fields", func(t *testing.T) {
})
t.Run("null nullable fields", func(t *testing.T) {
})
t.Run("invalid key", func(t *testing.T) {
})
t.Run("iterating", func(t *testing.T) {
})
})
t.Run("test parsing", func(t *testing.T) {
t.Run("strict order", func(t *testing.T) {
// FUTURE
})
})
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment