Files
micro/client/noop_test.go
pugnack 3e86864ce7
Some checks failed
test / test (push) Failing after 15m22s
coverage / build (push) Failing after 15m33s
[v3] remove using global map for default codecs (#224)
* remove using global map for default codecs

* fix tests
2025-10-15 21:33:32 +03:00

38 lines
696 B
Go

package client
import (
"context"
"testing"
"go.unistack.org/micro/v3/codec"
)
type testHook struct {
f bool
}
func (t *testHook) Publish(fn FuncPublish) FuncPublish {
return func(ctx context.Context, msg Message, opts ...PublishOption) error {
t.f = true
return fn(ctx, msg, opts...)
}
}
func TestNoopHook(t *testing.T) {
h := &testHook{}
c := NewClient(Codec("application/octet-stream", codec.NewCodec()), Hooks(HookPublish(h.Publish)))
if err := c.Init(); err != nil {
t.Fatal(err)
}
if err := c.Publish(context.TODO(), c.NewMessage("", nil, MessageContentType("application/octet-stream"))); err != nil {
t.Fatal(err)
}
if !h.f {
t.Fatal("hook not works")
}
}