Files
fleet/server/pubsub/testing_utils_test.go
T
Lucas Manuel Rodriguez 31c5a1b3ae Remove testing dependencies on production binaries on pubsub and dev_mode (#45296)
**Related issue:** Resolves #45220 (one of many PRs)

## Testing

- [X] QA'd all new/changed functionality manually.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Test utilities moved into test-only files and removed from production
code, reducing runtime dependencies and tightening module boundaries.
* **Tests**
* Updated test setup to use internal test helpers and explicit Redis
test setup, improving test isolation and reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-13 13:57:49 -03:00

20 lines
694 B
Go

package pubsub
import (
"log/slog"
"testing"
"github.com/fleetdm/fleet/v4/server/datastore/redis/redistest"
)
// setupRedisForTest builds a redisQueryResults backed by a freshly-created
// redistest pool. It is used by pubsub's own tests; external callers should
// build the store directly via NewRedisQueryResults so this helper doesn't
// have to live in a regular .go file (and pull "testing" into the production
// binary).
func setupRedisForTest(t *testing.T, cluster, readReplica bool) *redisQueryResults {
const dupResults = false
pool := redistest.SetupRedis(t, "zz", cluster, false, readReplica)
return NewRedisQueryResults(pool, dupResults, slog.New(slog.DiscardHandler))
}