• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 25600147486

09 May 2026 11:35AM UTC coverage: 34.005% (-31.1%) from 65.118%
25600147486

Pull #615

github

web-flow
Merge 7dc8a4461 into f9f6d647a
Pull Request #615: test: add unit tests for remaining app workers (#489)

788 of 3168 branches covered (24.87%)

Branch coverage included in aggregate %.

0 of 4 new or added lines in 2 files covered. (0.0%)

1822 existing lines in 87 files now uncovered.

2352 of 6066 relevant lines covered (38.77%)

20.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.86
/src/cache/client.ts
1
import { createClient, RedisClientOptions } from 'redis'
1✔
2
import { CacheClient } from '../@types/cache'
3
import { createLogger } from '../factories/logger-factory'
1✔
4

5
const logger = createLogger('cache-client')
1✔
6

7
const redactRedisUrlCredentials = (url: string): string => {
1✔
8
  try {
1✔
9
    const parsedUrl = new URL(url)
1✔
10

11
    if (!parsedUrl.username && !parsedUrl.password) {
1!
12
      return url
1✔
13
    }
14

15
    parsedUrl.username = parsedUrl.username ? '***' : ''
×
16
    parsedUrl.password = parsedUrl.password ? '***' : ''
×
17

18
    return parsedUrl.toString()
×
19
  } catch {
20
    return url
×
21
  }
22
}
23

24
export const getCacheConfig = (): RedisClientOptions => {
1✔
25
  const password = process.env.REDIS_PASSWORD
2✔
26

27
  if (process.env.REDIS_URI) {
2!
UNCOV
28
    return {
×
29
      url: process.env.REDIS_URI,
30
      ...(password ? { password } : {}),
×
31
    }
32
  }
33

34
  const host = process.env.REDIS_HOST
2✔
35
  const port = process.env.REDIS_PORT
2✔
36

37
  if (password) {
2!
38
    const username = process.env.REDIS_USER ?? 'default'
2!
39

40
    return {
2✔
41
      url: `redis://${host}:${port}`,
42
      username,
43
      password,
44
    }
45
  }
46

UNCOV
47
  return {
×
48
    url: `redis://${host}:${port}`,
49
  }
50
}
51

52
let instance: CacheClient | undefined = undefined
1✔
53

54
export const getCacheClient = (): CacheClient => {
1✔
55
  if (!instance) {
2✔
56
    const config = getCacheConfig()
1✔
57
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
58
    const { password: _, ...loggableConfig } = config
1✔
59
    logger('config: %o', {
1✔
60
      ...loggableConfig,
61
      ...(loggableConfig.url ? { url: redactRedisUrlCredentials(loggableConfig.url) } : {}),
1!
62
    })
63
    instance = createClient(config)
1✔
64
  }
65

66
  return instance
2✔
67
}
68

69
export const closeCacheClient = async (): Promise<void> => {
1✔
70
  if (instance?.isOpen) {
1!
71
    await instance.disconnect()
1✔
72
    instance = undefined
1✔
73
  }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc