1. 03 Jun, 2021 1 commit
    • Daniel Martí's avatar
      node/bindnode: start running all schema tests · 6042d4d8
      Daniel Martí authored
      We add node/tests.SchemaTestAll to simplify this task, meaning we don't
      need to duplicate all test func declarations in node/bindnode.
      SchemaTestAll is also flexible enough to allow running multiple
      sub-tests per schema test in the future.
      
      There were two remaining places in node/tests that still weren't using
      ipld.DeepEqual, so fix those.
      
      Finally, bindnode needed a couple of changes to fully support
      ipld.DeepEqual. Most notable is iteration over maps, which required a
      bit of a refactor to keep ordered keys.
      6042d4d8
  2. 02 Jun, 2021 1 commit
    • Daniel Martí's avatar
      node/tests: put most of the schema test cases here · 5b6e1d30
      Daniel Martí authored
      Along with a generic Engine interface, so that they can be reused for
      other ipld.Node implementations, such as bindnode.
      
      node/bindnode will start using these in a follow-up commit, since this
      one is large enough as is.
      
      Tested that all three forms of testing schema/gen/go still work:
      
      	go test
      
      	CGO_ENABLED=0 go test
      
      	go test -tags=skipgenbehavtests
      5b6e1d30
  3. 23 Mar, 2021 2 commits
  4. 25 Dec, 2020 1 commit
    • Daniel Martí's avatar
      all: rename schema.Kind to TypeKind, ipld.ReprKind to Kind · 2d7d25c4
      Daniel Martí authored
      As discussed on the issue thread, ipld.Kind and schema.TypeKind are more
      intuitive, closer to the spec wording, and just generally better in the
      long run.
      
      The changes are almost entirely automated via the commands below. Very
      minor changes were needed in some of the generators, and then gofmt.
      
      	sed -ri 's/\<Kind\(\)/TypeKind()/g' **/*.go
      	git checkout fluent # since it uses reflect.Value.Kind
      
      	sed -ri 's/\<Kind_/TypeKind_/g' **/*.go
      	sed -i 's/\<Kind\>/TypeKind/g' **/*.go
      	sed -i 's/ReprKind/Kind/g' **/*.go
      
      Plus manually undoing a few renames, as per Eric's review.
      
      Fixes #94.
      2d7d25c4
  5. 10 Sep, 2020 1 commit
    • Daniel Martí's avatar
      all: don't use buffers where readers suffice · 8e26c7e2
      Daniel Martí authored
      Buffers are not a good option for tests if the other side expects a
      reader. Otherwise, the code being tested could build assumptions around
      the reader stream being a single contiguous chunk of bytes, such as:
      
      	_ = r.(*bytes.Buffer).Bytes()
      
      This kind of hack might seem unlikely, but it's an easy mistake to make,
      especially with APIs like fmt which automatically call String methods.
      
      With bytes.Reader and strings.Reader, the types are much more
      restricted, so the tests need to be more faithful.
      8e26c7e2
  6. 05 Sep, 2020 2 commits
    • Eric Myhre's avatar
      e0e89d72
    • Eric Myhre's avatar
      New testcase system for exercising typed nodes; Revamp struct tests with it. · 5d732d47
      Eric Myhre authored
      This new system focuses on table-driven tests, and leans heavily upon
      json as a shorthand for expressing fixtures.
      
      It also makes a great deal more effort to exercise the different
      features of nodes (and their paired representation nodes) from all
      directions at once for each test datum, rather than requring that all
      be written out manually.
      
      The result is that the struct tests we've renovated have a lovely
      diffstat shrinkage: 111 insertions, 299 deletions...
      
      And yet the smaller line count results in *more* coverage.
      
      (Okay, the linecount increase for the testcase structure and helper
      methods is much bigger than the savings in fixture size... but,
      only *so far*.  I assume this will continue to pay off in the future.)
      
      Relatedly: a bug in struct map representations has been fixed.
      (It was the sibling of 5f589653, embarassingly.)  Thank goodness we now
      get proper coverage of this area.
      
      There's a few TODOs left to further expand the exercises, but those
      can slot in easily in subsequent commits.  Same goes for further
      expansion of usage of this new system.
      5d732d47