TestExecutorHasIsGeneric exercises the generic Has API across every event kind to ensure compileEvents is wired correctly. It guards against regressions where adding a new event to the Config struct silently fails to surface in Has/Dispatch.
(t *testing.T)
| 43 | // against regressions where adding a new event to the Config struct |
| 44 | // silently fails to surface in Has/Dispatch. |
| 45 | func TestExecutorHasIsGeneric(t *testing.T) { |
| 46 | t.Parallel() |
| 47 | |
| 48 | // Empty config: no event has hooks. |
| 49 | empty := NewExecutor(nil, "/tmp", nil) |
| 50 | for ev := range onlyHooks { |
| 51 | assert.Falsef(t, empty.Has(ev), "empty executor must not report Has(%s)", ev) |
| 52 | } |
| 53 | |
| 54 | // Cross-product: configuring event ev must light up Has(ev) and |
| 55 | // only Has(ev). |
| 56 | for ev, cfg := range onlyHooks { |
| 57 | exec := NewExecutor(cfg, "/tmp", nil) |
| 58 | for other := range onlyHooks { |
| 59 | if other == ev { |
| 60 | assert.Truef(t, exec.Has(other), "configuring %s must light up Has(%s)", ev, other) |
| 61 | } else { |
| 62 | assert.Falsef(t, exec.Has(other), "configuring %s must NOT light up Has(%s)", ev, other) |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // Unknown events fall through cleanly rather than panicking. |
| 68 | assert.False(t, empty.Has(EventType("does-not-exist"))) |
| 69 | } |
nothing calls this directly
no test coverage detected