@@ -2,6 +2,7 @@ import { strict as assert } from 'node:assert';
22import CLIENT_INFO from './CLIENT_INFO' ;
33import testUtils , { GLOBAL } from '../test-utils' ;
44import { parseArgs } from './generic-transformers' ;
5+ import { version } from '../../package.json' ;
56
67describe ( 'CLIENT INFO' , ( ) => {
78 testUtils . isVersionGreaterThanHook ( [ 6 , 2 ] ) ;
@@ -48,4 +49,89 @@ describe('CLIENT INFO', () => {
4849 }
4950 }
5051 } , GLOBAL . SERVERS . OPEN ) ;
52+
53+ testUtils . testWithClient ( 'client.clientInfo Redis < 7' , async client => {
54+ const reply = await client . clientInfo ( ) ;
55+ if ( ! testUtils . isVersionGreaterThan ( [ 7 ] ) ) {
56+ assert . strictEqual ( reply . libName , undefined , 'LibName should be undefined for Redis < 7' ) ;
57+ assert . strictEqual ( reply . libVer , undefined , 'LibVer should be undefined for Redis < 7' ) ;
58+ }
59+ } , GLOBAL . SERVERS . OPEN ) ;
60+
61+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 info disabled' , async client => {
62+ const reply = await client . clientInfo ( ) ;
63+ assert . equal ( reply . libName , '' ) ;
64+ assert . equal ( reply . libVer , '' ) ;
65+ } , {
66+ ...GLOBAL . SERVERS . OPEN ,
67+ clientOptions : {
68+ disableClientInfo : true
69+ }
70+ } ) ;
71+
72+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp unset, info enabled, tag set' , async client => {
73+ const reply = await client . clientInfo ( ) ;
74+ assert . equal ( reply . libName , 'node-redis(client1)' ) ;
75+ assert . equal ( reply . libVer , version ) ;
76+ } , {
77+ ...GLOBAL . SERVERS . OPEN ,
78+ clientOptions : {
79+ clientInfoTag : 'client1'
80+ }
81+ } ) ;
82+
83+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp unset, info enabled, tag unset' , async client => {
84+ const reply = await client . clientInfo ( ) ;
85+ assert . equal ( reply . libName , 'node-redis' ) ;
86+ assert . equal ( reply . libVer , version ) ;
87+ } , GLOBAL . SERVERS . OPEN ) ;
88+
89+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp2 info enabled' , async client => {
90+ const reply = await client . clientInfo ( ) ;
91+ assert . equal ( reply . libName , 'node-redis(client1)' ) ;
92+ assert . equal ( reply . libVer , version ) ;
93+ } , {
94+ ...GLOBAL . SERVERS . OPEN ,
95+ clientOptions : {
96+ RESP : 2 ,
97+ clientInfoTag : 'client1'
98+ }
99+ } ) ;
100+
101+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp2 info disabled' , async client => {
102+ const reply = await client . clientInfo ( ) ;
103+ assert . equal ( reply . libName , '' ) ;
104+ assert . equal ( reply . libVer , '' ) ;
105+ } , {
106+ ...GLOBAL . SERVERS . OPEN ,
107+ clientOptions : {
108+ disableClientInfo : true ,
109+ RESP : 2
110+ }
111+ } ) ;
112+
113+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp3 info enabled' , async client => {
114+ const reply = await client . clientInfo ( ) ;
115+ assert . equal ( reply . libName , 'node-redis(client1)' ) ;
116+ assert . equal ( reply . libVer , version ) ;
117+ } , {
118+ ...GLOBAL . SERVERS . OPEN ,
119+ clientOptions : {
120+ RESP : 3 ,
121+ clientInfoTag : 'client1'
122+ }
123+ } ) ;
124+
125+ testUtils . testWithClientIfVersionWithinRange ( [ [ 7 ] , 'LATEST' ] , 'client.clientInfo Redis>=7 resp3 info disabled' , async client => {
126+ const reply = await client . clientInfo ( ) ;
127+ assert . equal ( reply . libName , '' ) ;
128+ assert . equal ( reply . libVer , '' ) ;
129+ } , {
130+ ...GLOBAL . SERVERS . OPEN ,
131+ clientOptions : {
132+ disableClientInfo : true ,
133+ RESP : 3
134+ }
135+ } ) ;
136+
51137} ) ;
0 commit comments