MCPcopy
hub / github.com/nats-io/nats.go / TestEncBuiltinMarshalBool

Function TestEncBuiltinMarshalBool

test/enc_test.go:236–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestEncBuiltinMarshalBool(t *testing.T) {
237 s := RunServerOnPort(TEST_PORT)
238 defer s.Shutdown()
239
240 ec := NewDefaultEConn(t)
241 defer ec.Close()
242 ch := make(chan bool)
243 expected := make(chan bool, 1)
244
245 ec.Subscribe("enc_bool", func(b bool) {
246 val := <-expected
247 if b != val {
248 t.Fatal("Boolean values did not match")
249 }
250 ch <- true
251 })
252
253 expected <- false
254 ec.Publish("enc_bool", false)
255 if e := Wait(ch); e != nil {
256 if ec.LastError() != nil {
257 e = ec.LastError()
258 }
259 t.Fatalf("Did not receive the message: %s", e)
260 }
261
262 expected <- true
263 ec.Publish("enc_bool", true)
264 if e := Wait(ch); e != nil {
265 if ec.LastError() != nil {
266 e = ec.LastError()
267 }
268 t.Fatalf("Did not receive the message: %s", e)
269 }
270}
271
272func TestEncBuiltinExtendedSubscribeCB(t *testing.T) {
273 s := RunServerOnPort(TEST_PORT)

Callers

nothing calls this directly

Calls 8

NewDefaultEConnFunction · 0.85
FatalfMethod · 0.80
RunServerOnPortFunction · 0.70
WaitFunction · 0.70
SubscribeMethod · 0.65
PublishMethod · 0.65
CloseMethod · 0.45
LastErrorMethod · 0.45

Tested by

no test coverage detected