MCPcopy
hub / github.com/mochi-mqtt/server / TestHooksNonReturns

Function TestHooksNonReturns

hooks_test.go:229–263  ·  view source on GitHub ↗

coverage: also cover some empty functions

(t *testing.T)

Source from the content-addressed store, hash-verified

227
228// coverage: also cover some empty functions
229func TestHooksNonReturns(t *testing.T) {
230 h := new(Hooks)
231 cl := new(Client)
232
233 for i := 0; i < 2; i++ {
234 t.Run("step-"+strconv.Itoa(i), func(t *testing.T) {
235 // on first iteration, check without hook methods
236 h.OnStarted()
237 h.OnStopped()
238 h.OnSysInfoTick(new(system.Info))
239 h.OnSessionEstablish(cl, packets.Packet{})
240 h.OnSessionEstablished(cl, packets.Packet{})
241 h.OnDisconnect(cl, nil, false)
242 h.OnPacketSent(cl, packets.Packet{}, []byte{})
243 h.OnPacketProcessed(cl, packets.Packet{}, nil)
244 h.OnSubscribed(cl, packets.Packet{}, []byte{1})
245 h.OnUnsubscribed(cl, packets.Packet{})
246 h.OnPublished(cl, packets.Packet{})
247 h.OnPublishDropped(cl, packets.Packet{})
248 h.OnRetainMessage(cl, packets.Packet{}, 0)
249 h.OnRetainPublished(cl, packets.Packet{})
250 h.OnQosPublish(cl, packets.Packet{}, time.Now().Unix(), 0)
251 h.OnQosComplete(cl, packets.Packet{})
252 h.OnQosDropped(cl, packets.Packet{})
253 h.OnPacketIDExhausted(cl, packets.Packet{})
254 h.OnWillSent(cl, packets.Packet{})
255 h.OnClientExpired(cl)
256 h.OnRetainedExpired("a/b/c")
257
258 // on second iteration, check added hook methods
259 err := h.Add(new(modifiedHookBase), nil)
260 require.NoError(t, err)
261 })
262 }
263}
264
265func TestHooksOnConnectAuthenticate(t *testing.T) {
266 h := new(Hooks)

Callers

nothing calls this directly

Calls 15

OnStartedMethod · 0.65
OnStoppedMethod · 0.65
OnSysInfoTickMethod · 0.65
OnSessionEstablishMethod · 0.65
OnSessionEstablishedMethod · 0.65
OnDisconnectMethod · 0.65
OnPacketSentMethod · 0.65
OnPacketProcessedMethod · 0.65
OnSubscribedMethod · 0.65
OnUnsubscribedMethod · 0.65
OnPublishedMethod · 0.65
OnPublishDroppedMethod · 0.65

Tested by

no test coverage detected