@@ -2,13 +2,25 @@ package queue
22
33import (
44 "context"
5+ "net"
56 "testing"
7+ "time"
68
79 "github.com/xraph/forge"
810 "github.com/xraph/forge/errors"
911 "github.com/xraph/forge/internal/logger"
1012)
1113
14+ // requireService skips the test if the given TCP address is not reachable.
15+ func requireService (t * testing.T , addr , name string ) {
16+ t .Helper ()
17+ conn , err := net .DialTimeout ("tcp" , addr , 500 * time .Millisecond )
18+ if err != nil {
19+ t .Skipf ("skipping: %s not available at %s" , name , addr )
20+ }
21+ conn .Close ()
22+ }
23+
1224// Test all backend constructors and basic error paths
1325
1426func TestRedisQueue_Constructor (t * testing.T ) {
@@ -363,6 +375,8 @@ func TestNATSQueue_NotConnectedErrors(t *testing.T) {
363375// Test extension with different drivers
364376
365377func TestExtension_RedisDriver (t * testing.T ) {
378+ requireService (t , "localhost:6379" , "Redis" )
379+
366380 app := forge .New (
367381 forge .WithAppName ("test-app" ),
368382 forge .WithAppVersion ("1.0.0" ),
@@ -392,6 +406,8 @@ func TestExtension_RedisDriver(t *testing.T) {
392406}
393407
394408func TestExtension_RabbitMQDriver (t * testing.T ) {
409+ requireService (t , "localhost:5672" , "RabbitMQ" )
410+
395411 app := forge .New (
396412 forge .WithAppName ("test-app" ),
397413 forge .WithAppVersion ("1.0.0" ),
@@ -421,6 +437,8 @@ func TestExtension_RabbitMQDriver(t *testing.T) {
421437}
422438
423439func TestExtension_NATSDriver (t * testing.T ) {
440+ requireService (t , "localhost:4222" , "NATS" )
441+
424442 app := forge .New (
425443 forge .WithAppName ("test-app" ),
426444 forge .WithAppVersion ("1.0.0" ),
0 commit comments