forked from keighl/barkup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql_test.go
73 lines (61 loc) · 1.43 KB
/
mysql_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package barkup
import (
"strings"
"testing"
)
func Test_MySQL_Export_Pass(t *testing.T) {
m := MySQL{
Host: "localhost",
Port: "3306",
DB: "test",
User: "root",
Password: "cheese",
}
MysqlDumpCmd = "true"
TarCmd = "true"
result := m.Export()
expect(t, result.Error, (*Error)(nil))
}
func Test_MySQL_Export_FailDump(t *testing.T) {
m := MySQL{
Host: "localhost",
Port: "3306",
DB: "test",
User: "root",
Password: "cheese",
}
MysqlDumpCmd = "false"
TarCmd = "true"
result := m.Export()
refute(t, result.Error, (*Error)(nil))
}
func Test_MySQL_Export_FailTar(t *testing.T) {
m := MySQL{
Host: "localhost",
Port: "3306",
DB: "test",
User: "root",
Password: "cheese",
}
MysqlDumpCmd = "true"
TarCmd = "false"
result := m.Export()
refute(t, result.Error, (*Error)(nil))
}
func Test_MySQL_optionsDump(t *testing.T) {
m := MySQL{
Host: "localhost",
Port: "3306",
DB: "test",
User: "root",
Password: "cheese",
Options: []string{"--skip-extended-insert"},
}
options := strings.Join(m.dumpOptions(), " ")
expect(t, strings.Contains(options, "-h"), true)
expect(t, strings.Contains(options, "-P"), true)
expect(t, strings.Contains(options, "-u"), true)
expect(t, strings.Contains(options, "-p"), true)
expect(t, strings.Contains(options, "--skip-extended-insert"), true)
expect(t, strings.Contains(options, m.DB), true)
}