generated from grafana/xk6-sql-driver-ramsql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtls_test.go
50 lines (44 loc) · 1.38 KB
/
tls_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
48
49
50
// Adapted more or less unchanged from: https://github.com/grafana/xk6-sql/blob/v0.4.1/sql_test.go#L99
// It will have to be refactored.
package mysql
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPrefixConnectionString(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
connectionString string
want string
}{
{
name: "HappyPath",
connectionString: "root:password@tcp(localhost:3306)/mysql",
want: "root:password@tcp(localhost:3306)/mysql?tls=custom",
},
{
name: "WithExistingParams",
connectionString: "root:password@tcp(localhost:3306)/mysql?param=value",
want: "root:password@tcp(localhost:3306)/mysql?param=value&tls=custom",
},
{
name: "WithExistingTLSparam",
connectionString: "root:password@tcp(localhost:3306)/mysql?tls=custom",
want: "root:password@tcp(localhost:3306)/mysql?tls=custom",
},
{
name: "WithExistingTLSparam",
connectionString: "root:password@tcp(localhost:3306)/mysql?tls=notcustom",
want: "root:password@tcp(localhost:3306)/mysql?tls=notcustom&tls=custom",
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := prefixConnectionString(tc.connectionString, "custom")
require.Equal(t, tc.want, got)
})
}
}