-
Notifications
You must be signed in to change notification settings - Fork 9
/
poolset_test.go
47 lines (38 loc) · 1.01 KB
/
poolset_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ephemerald_test
import (
"context"
"testing"
"time"
"github.com/Sirupsen/logrus"
"github.com/boz/ephemerald"
"github.com/boz/ephemerald/config"
"github.com/boz/ephemerald/ui"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPoolSet(t *testing.T) {
log := logrus.New()
log.Level = logrus.DebugLevel
uie := ui.NewNoopEmitter()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
configs, err := config.ReadFile(log, uie, "_testdata/pools.json")
require.NoError(t, err)
set, err := ephemerald.NewPoolSet(log, ctx, configs)
require.NoError(t, err)
defer set.Stop()
require.NoError(t, set.WaitReady())
pset, err := set.Checkout()
require.NoError(t, err)
defer set.ReturnAll(pset)
rparam, ok := pset["redis"]
if assert.True(t, ok) &&
assert.NotNil(t, rparam) &&
assert.NotEmpty(t, rparam.Url) {
}
pgparam, ok := pset["postgres"]
if assert.True(t, ok) &&
assert.NotNil(t, pgparam) &&
assert.NotEmpty(t, pgparam.Url) {
}
}