@@ -753,7 +753,7 @@ func TestCollector_updateNginxAppProtectTcplogReceivers(t *testing.T) {
753753 require .NoError (t , err )
754754
755755 nginxConfigContext := & model.NginxConfigContext {
756- NAPSysLogServers : [] string { "localhost:15632" } ,
756+ NAPSysLogServer : "localhost:15632" ,
757757 }
758758
759759 assert .Empty (t , conf .Collector .Receivers .TcplogReceivers )
@@ -786,7 +786,7 @@ func TestCollector_updateNginxAppProtectTcplogReceivers(t *testing.T) {
786786 t .Run ("Test 4: NewCollector tcplogReceiver added and deleted another" , func (tt * testing.T ) {
787787 tcplogReceiverDeleted := collector .updateNginxAppProtectTcplogReceivers (ctx ,
788788 & model.NginxConfigContext {
789- NAPSysLogServers : [] string { "localhost:1555" } ,
789+ NAPSysLogServer : "localhost:1555" ,
790790 },
791791 )
792792
@@ -939,49 +939,49 @@ func TestCollector_findAvailableSyslogServers(t *testing.T) {
939939 name string
940940 expectedSyslogServer string
941941 previousNAPSysLogServer string
942- syslogServers [] string
942+ syslogServers string
943943 portInUse bool
944944 }{
945945 {
946946 name : "Test 1: port available" ,
947947 expectedSyslogServer : "localhost:15632" ,
948948 previousNAPSysLogServer : "" ,
949- syslogServers : [] string { "localhost:15632" } ,
949+ syslogServers : "localhost:15632" ,
950950 portInUse : false ,
951951 },
952952 {
953953 name : "Test 2: port in use" ,
954954 expectedSyslogServer : "" ,
955955 previousNAPSysLogServer : "" ,
956- syslogServers : [] string { "localhost:15632" } ,
956+ syslogServers : "localhost:15632" ,
957957 portInUse : true ,
958958 },
959959 {
960960 name : "Test 3: syslog server already configured" ,
961961 expectedSyslogServer : "localhost:15632" ,
962962 previousNAPSysLogServer : "localhost:15632" ,
963- syslogServers : [] string { "localhost:15632" } ,
963+ syslogServers : "localhost:15632" ,
964964 portInUse : false ,
965965 },
966966 {
967967 name : "Test 4: new syslog server" ,
968968 expectedSyslogServer : "localhost:15632" ,
969969 previousNAPSysLogServer : "localhost:1122" ,
970- syslogServers : [] string { "localhost:15632" } ,
970+ syslogServers : "localhost:15632" ,
971971 portInUse : false ,
972972 },
973973 {
974- name : "Test 5 : port in use find next server " ,
974+ name : "Test 6 : port hasn't changed " ,
975975 expectedSyslogServer : "localhost:1122" ,
976- previousNAPSysLogServer : "" ,
977- syslogServers : [] string { "localhost:15632" , "localhost: 1122"} ,
976+ previousNAPSysLogServer : "localhost:1122 " ,
977+ syslogServers : "localhost:1122" ,
978978 portInUse : true ,
979979 },
980980 {
981- name : "Test 6 : port hasn't changed" ,
981+ name : "Test 7 : port hasn't changed, but is now localhost " ,
982982 expectedSyslogServer : "localhost:1122" ,
983- previousNAPSysLogServer : "localhost :1122" ,
984- syslogServers : [] string { "localhost:1122" } ,
983+ previousNAPSysLogServer : "127.0.0.1 :1122" ,
984+ syslogServers : "localhost:1122" ,
985985 portInUse : true ,
986986 },
987987 }
@@ -994,12 +994,12 @@ func TestCollector_findAvailableSyslogServers(t *testing.T) {
994994
995995 if test .portInUse {
996996 listenConfig := & net.ListenConfig {}
997- ln , listenError := listenConfig .Listen (ctx , "tcp" , "localhost:15632" )
997+ ln , listenError := listenConfig .Listen (ctx , "tcp" , test . syslogServers )
998998 require .NoError (t , listenError )
999999 defer ln .Close ()
10001000 }
10011001
1002- actual := collector .findAvailableSyslogServers (ctx , test .syslogServers )
1002+ actual := collector .findAvailableSyslogServer (ctx , test .syslogServers )
10031003 assert .Equal (tt , test .expectedSyslogServer , actual )
10041004 })
10051005 }
0 commit comments