**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 -->
20 lines
694 B
Go
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))
|
|
}
|