go-fed/activity

New tests for v1 pub

Closed this issue · 6 comments

Add or port unit tests for the v1 pub package.

base_actor is now covered
52bc5fb

Remaining:

  • side_effect_actor.go
  • federating_wrapped_callbacks.go
  • social_wrapped_callbacks.go
  • transport.go
  • More stuff in util.go

As of b4b18b9

  • 79 unit tests are passing
  • 216 total identified unit test cases
  • Estimated 100 more unit test cases to be identified

This roughly puts unit test completeness at 25%.

Storytime:

  • I thought doing the AddNewIds test would be straightforward.
  • Uncovered bug where I was using IsExtendedBy checks everywhere for a Type T.
  • This passes for all child types of T but fails for T itself. As designed. D'oh!
  • Had to do commits 1ed044f (and cough 42b7993) to generate new IsOrExtends methods that is closed on T (passes for child types of T and T itself)
  • Fix the bug and get passing unit tests in 1ea8e2c

This is why I unit test. Still many more to go.

I broke a bunch of tests at some point when building out apcore.

Requires re-running the mockgen tool and fixing the expectations.

  • f2a497b fixes the broken tests
  • d11b96b implements unit tests for federating Create behavior
  • c994dc3 implements unit tests for federating Accept and Reject behavior

Been on a sprint to get as much unit testing done as possible. The only place left that needs unit tests is the C2S code (social_wrapped_callbacks.go). Due to lack of popularity, I'm not going to tackle those at this time.

The command go test -coverprofile=t.out reports coverage: 71.0% of statements.

The command go test -v | grep -c PASS over-counts the number of tests since they're grouped into subtests, so while it reports 233, the true number is probably in the 200-ish range.

The command go tool cover -html=t.out reports per-file coverage as (ordered highest to lowest):

file % coverage
version.go 100.0%
transport.go 89.8%
federating_wrapped_callbacks.go 82.6%
handlers.go 80.6%
side_effect_actor.go 78.1%
base_actor.go 75.0%
util.go 72.9%
social_wrapped_callbacks.go 25.8%

Marking closed.