fix(test): use REDIS_ADDR environment variable in cron test mocks to match CI service hostname
Some checks failed
CI / lint (push) Failing after 11s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / docker (push) Has been skipped

This commit is contained in:
2026-08-20 17:56:05 +03:00
parent e73ed82b7e
commit 900db58043

View File

@@ -14,7 +14,16 @@ import (
) )
func newMockMonitor(id string, tripCount int, scheduleFunc func(context.Context, string) (int, error)) *StationMonitor { func newMockMonitor(id string, tripCount int, scheduleFunc func(context.Context, string) (int, error)) *StationMonitor {
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
yc := yandex.NewClient("test-key") yc := yandex.NewClient("test-key")
monitor := &StationMonitor{ monitor := &StationMonitor{
@@ -40,7 +49,16 @@ const testMonitorID = "test-station"
// gets status "active" and zero-trip day count resets to 0. // gets status "active" and zero-trip day count resets to 0.
func TestProcessStation_WithTrips(t *testing.T) { func TestProcessStation_WithTrips(t *testing.T) {
t.Helper() t.Helper()
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
defer rc.Close() defer rc.Close()
ctx := context.Background() ctx := context.Background()
@@ -84,7 +102,16 @@ func TestProcessStation_WithTrips(t *testing.T) {
// with 0 trips increments the zero-trip day count. // with 0 trips increments the zero-trip day count.
func TestProcessStation_ZeroTrips_IncrementsCount(t *testing.T) { func TestProcessStation_ZeroTrips_IncrementsCount(t *testing.T) {
t.Helper() t.Helper()
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
defer rc.Close() defer rc.Close()
ctx := context.Background() ctx := context.Background()
@@ -128,7 +155,16 @@ func TestProcessStation_ZeroTrips_IncrementsCount(t *testing.T) {
// with 3 consecutive days of zero trips gets status "closed". // with 3 consecutive days of zero trips gets status "closed".
func TestProcessStation_ZeroTrips_3Days_Closes(t *testing.T) { func TestProcessStation_ZeroTrips_3Days_Closes(t *testing.T) {
t.Helper() t.Helper()
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
defer rc.Close() defer rc.Close()
ctx := context.Background() ctx := context.Background()
@@ -190,7 +226,16 @@ func TestProcessStation_ZeroTrips_3Days_Closes(t *testing.T) {
// closed due to 3 zero-trip days gets reactivated when trips resume. // closed due to 3 zero-trip days gets reactivated when trips resume.
func TestProcessStation_Reactivation_AfterClosure(t *testing.T) { func TestProcessStation_Reactivation_AfterClosure(t *testing.T) {
t.Helper() t.Helper()
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
defer rc.Close() defer rc.Close()
ctx := context.Background() ctx := context.Background()
@@ -240,7 +285,16 @@ func TestProcessStation_Reactivation_AfterClosure(t *testing.T) {
// and that it reactivates when trips resume. // and that it reactivates when trips resume.
func TestAutoClosureChronology(t *testing.T) { func TestAutoClosureChronology(t *testing.T) {
t.Helper() t.Helper()
rc := redis.NewClient(&redis.Options{Addr: "localhost:6379"}) // Read Redis address from environment, default to localhost:6379
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "localhost:6379"
}
rc := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: 0,
})
defer rc.Close() defer rc.Close()
ctx := context.Background() ctx := context.Background()