MSSQL loadable plugin
Source
dsn: "pigeon://rrrr:tttt@uri:1433?app+name=Zabbix+agent+2+MSSQL+plugin&keepAlive=0",
/*
** Zabbix
** Copyright (C) 2001-2024 Zabbix SIA
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**/
package dbconn
import (
"context"
"database/sql"
"database/sql/driver"
"errors"
stdlog "log"
"os"
"sync"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"golang.zabbix.com/plugin/mssql/plugin/params"
"golang.zabbix.com/sdk/log"
)
var (
_ driver.Driver = (*driverMock)(nil)
_ driver.DriverContext = (*driverMock)(nil)
_ driver.Connector = (*connectorMock)(nil)
//nolint:gochecknoglobals // global driver instance.
mockDriver = &driverMock{}
)
type connectorMock struct {
driver driver.Driver
name string
}
type driverMock struct {
openErr error
driver driver.Driver
}
//nolint:gochecknoinits
func init() {
sql.Register("testdriver", mockDriver)
}
func (d *driverMock) Open(name string) (driver.Conn, error) {
if d.openErr != nil {
return nil, d.openErr