forked from mystiq/dex
Fix sqlite an mysql tests
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
parent
fb38e1235d
commit
4d4edaf540
2 changed files with 1 additions and 46 deletions
|
@ -148,48 +148,3 @@ func TestMySQLDSN(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMySQLDriver(t *testing.T) {
|
||||
host := os.Getenv(MySQLEntHostEnv)
|
||||
if host == "" {
|
||||
t.Skipf("test environment variable %s not set, skipping", MySQLEntHostEnv)
|
||||
}
|
||||
|
||||
port := uint64(3306)
|
||||
if rawPort := os.Getenv(MySQLEntPortEnv); rawPort != "" {
|
||||
var err error
|
||||
|
||||
port, err = strconv.ParseUint(rawPort, 10, 32)
|
||||
require.NoError(t, err, "invalid mysql port %q: %s", rawPort, err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg func() *MySQL
|
||||
desiredConns int
|
||||
}{
|
||||
{
|
||||
name: "Defaults",
|
||||
cfg: func() *MySQL { return mysqlTestConfig(host, port) },
|
||||
desiredConns: 5,
|
||||
},
|
||||
{
|
||||
name: "Tune",
|
||||
cfg: func() *MySQL {
|
||||
cfg := mysqlTestConfig(host, port)
|
||||
cfg.MaxOpenConns = 101
|
||||
return cfg
|
||||
},
|
||||
desiredConns: 101,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
drv, err := tt.cfg().driver()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, tt.desiredConns, drv.DB().Stats().MaxOpenConnections)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func (s *SQLite3) Open(logger log.Logger) (storage.Storage, error) {
|
|||
// always allow only one connection to sqlite3, any other thread/go-routine
|
||||
// attempting concurrent access will have to wait
|
||||
pool := drv.DB()
|
||||
pool.SetMaxOpenConns(1)
|
||||
pool.SetMaxOpenConns(5)
|
||||
|
||||
databaseClient := client.NewDatabase(
|
||||
client.WithClient(db.NewClient(db.Driver(drv))),
|
||||
|
|
Loading…
Reference in a new issue