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

Function TestEncBuiltinMarshalString

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

Source from the content-addressed store, hash-verified

59}
60
61func TestEncBuiltinMarshalString(t *testing.T) {
62 s := RunServerOnPort(TEST_PORT)
63 defer s.Shutdown()
64
65 ec := NewDefaultEConn(t)
66 defer ec.Close()
67 ch := make(chan bool)
68
69 testString := "Hello World!"
70
71 ec.Subscribe("enc_string", func(s string) {
72 if s != testString {
73 t.Fatalf("Received test string of '%s', wanted '%s'\n", s, testString)
74 }
75 ch <- true
76 })
77 ec.Publish("enc_string", testString)
78 if e := Wait(ch); e != nil {
79 if ec.LastError() != nil {
80 e = ec.LastError()
81 }
82 t.Fatalf("Did not receive the message: %s", e)
83 }
84}
85
86func TestEncBuiltinMarshalBytes(t *testing.T) {
87 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