MCPcopy
hub / github.com/redis/go-redis / TestOnCloseHooks_RunInRegistrationOrder

Function TestOnCloseHooks_RunInRegistrationOrder

internal_test.go:812–827  ·  view source on GitHub ↗

TestOnCloseHooks_RunInRegistrationOrder verifies that hooks registered under distinct ids are all invoked on run() in the order they were registered.

(t *testing.T)

Source from the content-addressed store, hash-verified

810// TestOnCloseHooks_RunInRegistrationOrder verifies that hooks registered under
811// distinct ids are all invoked on run() in the order they were registered.
812func TestOnCloseHooks_RunInRegistrationOrder(t *testing.T) {
813 h := &onCloseHooks{}
814 var calls []string
815
816 h.register("a", func() error { calls = append(calls, "a"); return nil })
817 h.register("b", func() error { calls = append(calls, "b"); return nil })
818 h.register("c", func() error { calls = append(calls, "c"); return nil })
819
820 if err := h.run(); err != nil {
821 t.Fatalf("unexpected error: %v", err)
822 }
823 want := []string{"a", "b", "c"}
824 if !reflect.DeepEqual(calls, want) {
825 t.Fatalf("run order = %v, want %v", calls, want)
826 }
827}
828
829// TestOnCloseHooks_RegisterSameIDReplaces is the regression test for issue
830// #3772. Registering the same id repeatedly must replace the existing

Callers

nothing calls this directly

Calls 2

registerMethod · 0.95
runMethod · 0.95

Tested by

no test coverage detected