forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
39 lines (34 loc) · 951 Bytes
/
main_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
package main
import (
"testing"
"github.com/stellar/go/support/db/dbtest"
"github.com/stellar/go/support/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestInitDriver_dialect(t *testing.T) {
c := Config{}
testCases := []struct {
dbType string
dbDSN string
wantErr error
}{
{dbType: "", wantErr: errors.New("Invalid db type: ")},
{dbType: "postgres", dbDSN: dbtest.Postgres(t).DSN, wantErr: nil},
{dbType: "mysql", wantErr: errors.New("Invalid db type: mysql, mysql support is discontinued")},
{dbType: "bogus", wantErr: errors.New("Invalid db type: bogus")},
}
for _, tc := range testCases {
t.Run(tc.dbType, func(t *testing.T) {
c.Database.Type = tc.dbType
c.Database.DSN = tc.dbDSN
_, err := initDriver(c)
if tc.wantErr == nil {
require.Nil(t, err)
} else {
require.NotNil(t, err)
assert.Equal(t, tc.wantErr.Error(), err.Error())
}
})
}
}