** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
"golang.zabbix.com/sdk/uri"
func TestConnManager_closeUnused(t *testing.T) {
connMgr := NewConnManager(1*time.Microsecond, 30*time.Second, hkInterval*time.Second)
uri, _ := uri.New("tcp://127.0.0.1", nil)
t.Run("Unused connections should have been deleted", func(t *testing.T) {
if len(connMgr.connections) != 0 {
t.Errorf("connMgr.connections expected to be empty, but actual length is %d", len(connMgr.connections))
func TestConnManager_closeAll(t *testing.T) {
connMgr := NewConnManager(300*time.Second, 30*time.Second, hkInterval*time.Second)
uri, _ := uri.New("tcp://127.0.0.1", nil)
t.Run("All connections should have been deleted", func(t *testing.T) {
if len(connMgr.connections) != 0 {
t.Errorf("connMgr.connections expected to be empty, but actual length is %d", len(connMgr.connections))
func TestConnManager_create(t *testing.T) {
u, _ := uri.New("tcp://127.0.0.1", nil)
connMgr := NewConnManager(300*time.Second, 30*time.Second, hkInterval*time.Second)