fix: skip NATS connection when URL is empty

(cherry picked from commit a3c05b41717bc652ef7736cc2c2b22c4eaed0f5d)
This commit is contained in:
root authored and Jorge Fernando dos Santos committed 2026-11-09 12:01:00 -03:00
1 parent 3cc5192b7b
commit a4add7cc5e
2 files changed
+26

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
package nats_producer
import "testing"
func TestNewNatsProducerDoesNotConnectWithoutURL(t *testing.T) {
producer, ok := NewNatsProducer(" ", false, nil, nil).(*natsProducer)
if !ok {
t.Fatal("constructor returned an unexpected producer type")
}
if producer.conn != nil {
t.Fatal("NATS connection must stay nil when NATS_URL is empty")
}
if producer.natsGlobalEnabled {
t.Fatal("NATS global publishing must stay disabled without a URL")
}
}