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

Function TestPublishErrorAfterInvalidPublishMessage

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

Source from the content-addressed store, hash-verified

515}
516
517func TestPublishErrorAfterInvalidPublishMessage(t *testing.T) {
518 ts := RunServerOnPort(ENC_TEST_PORT)
519 defer ts.Shutdown()
520 opts := options
521 nc, _ := opts.Connect()
522 defer nc.Close()
523 c, _ := nats.NewEncodedConn(nc, protobuf.PROTOBUF_ENCODER)
524 const testSubj = "test"
525
526 c.Publish(testSubj, &testdata.Person{Name: "Anatolii"})
527
528 // Publish invalid protobuf message to catch decode error
529 c.Publish(testSubj, "foo")
530
531 // Next publish with valid protobuf message should be successful
532 if err := c.Publish(testSubj, &testdata.Person{Name: "Anatolii"}); err != nil {
533 t.Error("Fail to send correct protobuf message after invalid message publishing", err)
534 }
535}
536
537func TestVariousFailureConditions(t *testing.T) {
538 ts := RunServerOnPort(ENC_TEST_PORT)

Callers

nothing calls this directly

Calls 5

PublishMethod · 0.95
ConnectMethod · 0.80
RunServerOnPortFunction · 0.70
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected