1
- import {
2
- getTCPEndpoints ,
3
- } from 'src/utils/auto-discovery-helper' ;
4
-
5
- const winNetstat = ''
1
+ export const mockWinNetstat = ''
6
2
+ 'Proto Local Address Foreign Address State PID\n'
7
3
+ 'TCP 0.0.0.0:5000 0.0.0.0:0 LISTENING 13728\n'
8
4
+ 'TCP 0.0.0.0:6379 0.0.0.0:0 LISTENING 13728\n'
@@ -15,7 +11,7 @@ const winNetstat = ''
15
11
+ 'TCP [::]:5000 [::]:0 LISTENING 6056\n'
16
12
+ 'TCP *:* LISTENING 6056' ;
17
13
18
- const linuxNetstat = ''
14
+ export const mockLinuxNetstat = ''
19
15
+ 'Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name \n'
20
16
+ 'tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN - \n'
21
17
+ 'tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN - \n'
@@ -30,7 +26,7 @@ const linuxNetstat = ''
30
26
+ 'tcp6 0 0 ::1:6379 :::* LISTEN - \n' ;
31
27
32
28
/* eslint-disable max-len */
33
- const macNetstat = ''
29
+ export const mockMacNetstat = ''
34
30
+ 'Proto Recv-Q Send-Q Local Address Foreign Address (state) rhiwat shiwat pid epid state options\n'
35
31
+ 'tcp4 0 0 10.55.1.235.5000 10.55.1.235.52217 FIN_WAIT_2 407280 146988 30555 0 0x2131 0x00000104\n'
36
32
+ 'tcp4 0 0 10.55.1.235.6379 10.55.1.235.5001 CLOSE_WAIT 407682 146988 872 0 0x0122 0x00000008\n'
@@ -40,54 +36,7 @@ const macNetstat = ''
40
36
+ 'tcp6 0 0 ::1.52167 ::1.5002 ESTABLISHED 406172 146808 31200 0 0x0102 0x00000008\n' ;
41
37
/* eslint-enable max-len */
42
38
43
- const getTCPEndpointsTests = [
44
- {
45
- name : 'win output' ,
46
- input : winNetstat . split ( '\n' ) ,
47
- output : [
48
- { host : 'localhost' , port : 5000 } ,
49
- { host : 'localhost' , port : 6379 } ,
50
- { host : 'localhost' , port : 6380 } ,
51
- { host : 'localhost' , port : 135 } ,
52
- { host : 'localhost' , port : 445 } ,
53
- { host : 'localhost' , port : 808 } ,
54
- { host : 'localhost' , port : 2701 } ,
55
- ] ,
56
- } ,
57
- {
58
- name : 'linux output' ,
59
- input : linuxNetstat . split ( '\n' ) ,
60
- output : [
61
- { host : 'localhost' , port : 5000 } ,
62
- { host : 'localhost' , port : 6379 } ,
63
- { host : 'localhost' , port : 6380 } ,
64
- { host : 'localhost' , port : 28100 } ,
65
- { host : 'localhost' , port : 8100 } ,
66
- { host : 'localhost' , port : 8101 } ,
67
- { host : 'localhost' , port : 8102 } ,
68
- { host : 'localhost' , port : 8103 } ,
69
- { host : 'localhost' , port : 8200 } ,
70
- ] ,
71
- } ,
72
- {
73
- name : 'mac output' ,
74
- input : macNetstat . split ( '\n' ) ,
75
- output : [
76
- { host : 'localhost' , port : 5000 } ,
77
- { host : 'localhost' , port : 6379 } ,
78
- { host : 'localhost' , port : 6380 } ,
79
- { host : 'localhost' , port : 5002 } ,
80
- { host : 'localhost' , port : 52167 } ,
81
- ] ,
82
- } ,
83
- ] ;
84
-
85
- describe ( 'getTCP4Endpoints' , ( ) => {
86
- getTCPEndpointsTests . forEach ( ( test ) => {
87
- it ( `Should return endpoints to test ${ test . name } ` , async ( ) => {
88
- const result = getTCPEndpoints ( test . input ) ;
89
-
90
- expect ( result ) . toEqual ( test . output ) ;
91
- } ) ;
92
- } ) ;
93
- } ) ;
39
+ export const mockAutodiscoveryEndpoint = {
40
+ host : '127.0.0.1' ,
41
+ port : 6379 ,
42
+ } ;
0 commit comments