E0079: mock_target
E0079 mock_target — a mock naming no handler.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0079).
The rule
A mock line in a test must name a handler or a builtin that the program can call; a mock naming nothing would never fire, and the test would pass without the mock ever being used. Fix the name so that it matches the handler (here mock price_of 250).
A program that triggers it
wrong.cell
cell Checkout {
on price_of(sku: String) {
return 100
}
on total(sku: String, qty: Int) {
return price_of(sku) * qty
}
}
cell test CheckoutTests {
rules {
mock price 250
assert total("book", 2) == 500
}
}What soma check prints:
$ soma check wrong.cell
error: `mock price`: no handler or builtin named `price` — this mock would never fire
--> wrong.cell:12:9
|
12 | mock price 250
| ^
= code: E0079
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: this mock would never fire
The fix
On line 12, mock price 250 becomes mock price_of 250.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -10,5 +10,5 @@
cell test CheckoutTests {
rules {
- mock price 250
+ mock price_of 250
assert total("book", 2) == 500
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.