From 0a73394c23b2a2164ee051d05c1af08e052eb361 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 15 Sep 2026 12:51:17 +1000 Subject: [PATCH] fix(servicediscovery/nats): validate config after defaults Root-cause fix: Connect validated the raw config before withDefaults, so the Heartbeat= TTL). +func TestConnectRejectsTTLBelowDefaultHeartbeat(t *testing.T) { + _, err := Connect(context.Background(), Config{URL: "nats://127.0.0.1:1", TTL: 2 * time.Second}, discardLogger()) + if !errors.Is(err, ErrInvalidConfig) { + t.Fatalf("Connect() = %v, want ErrInvalidConfig", err) + } +} + // newServer starts a real in-process NATS server with JetStream enabled. This // is the established test technique for the NATS infrastructure (see the // sibling eventbus/nats retention test): a real server, not a mocked client.