Skip to content

v1: Verify operation results against an oracle; add negative-path tests

Choose a tag to compare

@NLstn NLstn released this 11 Jul 08:24
12.1_operations.go and 11.4.13_action_function_parameters.go checked
only HTTP status and response shape for functions/actions, never the
actual computed result or side effect against the seeded fixture
data — trivially checkable given the suite already knows the exact
seed values.

- test_unbound_function / test_operation_returns_collection
  (GetTopProducts()): now verifies the full result is sorted
  descending by Price and matches the complete product set.
- test_unbound_function_parameters (GetTopProducts(count=3)): verifies
  the exact top-3 products by Price, in order.
- test_bound_function (GetTotalPrice(taxRate=0.08)): verifies the
  returned value equals Price * 1.08 for the target entity.
- test_bound_function_collection (GetAveragePrice()): verifies the
  returned value equals the true average Price across all products.
- test_bound_action (ApplyDiscount(percentage=10)): now re-GETs the
  entity afterward and verifies Price actually became
  originalPrice * 0.9, not just that the action's own response
  succeeded.
- 11.4.13's test_function_valid_params (FindProducts): now verifies
  the exact result set (name substring AND maxPrice), not just 200.
- New negative-path tests: function invoked via POST is rejected,
  action invoked via GET is rejected, and a bound function missing a
  required parameter / given a wrong-typed parameter is rejected —
  none of these were tested anywhere before.

Left test_unbound_action (ResetProducts) unchanged: empirically it
does not revert a product's Price back to its seed value after a
prior ApplyDiscount call, but its name and lack of documentation don't
give enough confidence to assert a specific intended side effect, so
no unverified requirement was added.

Verified all behaviors against a live go-odata reference server before
writing assertions. Full build/vet/test clean; full-suite run shows no
regressions (test count rose by exactly the 4 new negative tests
added).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>