-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig_test.go
More file actions
49 lines (45 loc) · 973 Bytes
/
config_test.go
File metadata and controls
49 lines (45 loc) · 973 Bytes
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
48
49
package f_test
import (
"database/sql"
f "github.com/og/gofree"
"github.com/stretchr/testify/assert"
"testing"
)
func ExampleCreateDataSourceName() {
dataSourceName := f.DataSourceName{
User: "root",
Password: "password",
Host: "localhost",
Port: "3306",
DB: "test_gofree",
}.GetString()
sql.Open("mysql", dataSourceName)
}
func TestCreateDataSourceName(t *testing.T) {
// ignore User
assert.Equal(t,
"root:password@(localhost:3306)/test_gofree?charset=utf8&loc=Local&parseTime=True",
f.DataSourceName{
User: "root",
Password: "password",
Host: "localhost",
Port: "3306",
DB: "test_gofree",
}.GetString(),
)
// use User
assert.Equal(t,
"root:password@(localhost:3306)/test_gofree?charset=gb&loc=local",
f.DataSourceName{
User: "root",
Password: "password",
Host: "localhost",
Port: "3306",
DB: "test_gofree",
Query: map[string]string{
"charset": "gb",
"loc": "local",
},
}.GetString(),
)
}